Skip to content

Instantly share code, notes, and snippets.

@ir4y
Created November 27, 2013 04:48
Show Gist options
  • Select an option

  • Save ir4y/7670809 to your computer and use it in GitHub Desktop.

Select an option

Save ir4y/7670809 to your computer and use it in GitHub Desktop.
#!/bin/bash
#usage change_owner.sh database_name new_owner_name
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" $1` ; do
psql -c "alter table $tbl owner to $2" $1 ;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment