Last active
October 15, 2018 18:31
-
-
Save jnm/23a514b5db4290b09ede to your computer and use it in GitHub Desktop.
Change owner of all tables in a database using pure PostgreSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO | |
$$ | |
DECLARE | |
row record; | |
BEGIN | |
FOR row IN SELECT table_name FROM information_schema.tables | |
WHERE table_schema <> 'pg_catalog' AND table_schema <> 'information_schema' AND table_catalog = 'kobotoolbox' | |
LOOP | |
EXECUTE 'ALTER TABLE ' || quote_ident(row.table_name) || ' OWNER TO kobo;'; | |
END LOOP; | |
END; | |
$$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment