Skip to content

Instantly share code, notes, and snippets.

@dbalan
Created May 26, 2014 11:48
Show Gist options
  • Save dbalan/2fa6e07af8a07561eafb to your computer and use it in GitHub Desktop.
Save dbalan/2fa6e07af8a07561eafb to your computer and use it in GitHub Desktop.
#!/bin/bash
# change table owners for a databse - postgresql
ALTER DATABSE dbname OWNER TO username;
for tbl in $(psql -qAt -c "SELECT TABLENAME FROM pg_tables WHERE schemaname = 'public';" $DATABASE);
do
psql -c "alter table $tbl owner to $NEW_OWNER" $DATABASE ; done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment