Last active
May 5, 2022 19:51
-
-
Save we4tech/857e93b179fbaec439ae246acbb21901 to your computer and use it in GitHub Desktop.
PostgresSQL alter owner for all tables
This file contains hidden or 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
-- Geneate query | |
SELECT format('alter table %s owner to root;', tablename) FROM pg_tables WHERE schemaname = 'public' | |
-- On psql execute \gexec to eval all above queries. | |
\gexec | |
-- Generate query for sequences | |
select format('alter sequence %s owner to root;', sequencename) FROM pg_sequences WHERE schemaname = 'public'; | |
\gexec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment