Last active
August 29, 2015 14:22
-
-
Save develost/0be159559e5e0667ba44 to your computer and use it in GitHub Desktop.
Bulk change owner tables in multiple schema postgres
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
--------------------------------------------------------------------------------- | |
--- Bulk alter table owner for all tables in multiple schema | |
--- to be run into pgAdmin "Execute pgScript" | |
--------------------------------------------------------------------------------- | |
--- hint: replace MY_USER with your actual user | |
SET @elements = select schemaname, tablename from pg_tables where schemaname in ('public','test','whatever'); | |
SET @i = 0; | |
WHILE @i < LINES(@elements) | |
BEGIN | |
SET @T = @elements[@i][0] + '.' + @elements[@i][1]; | |
ALTER TABLE @T OWNER TO MY_USER; | |
SET @i = @i +1; | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment