From: | Greg Spiegelberg <gspiegelberg(at)gmail(dot)com> |
---|---|
To: | Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov> |
Cc: | Lance Campbell <lance(at)illinois(dot)edu>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: How to change all owners on all objects in a schema |
Date: | 2011-06-23 21:03:04 |
Message-ID: | BANLkTimHR07oOuqeUp-ix73tnxw8zbbL6w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
On Thu, Jun 23, 2011 at 2:41 PM, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov
> wrote:
> "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> wrote:
>
> > || ' set schema newschema;'
>
> Oops; you wanted to change the owner, but I'll leave that as an
> exercise for the reader. :-)
>
>
Beat me to it :)
Replace <SCHEMA>, <NEW_OWNER> and <DATABASE>
psql -qAt -d <DATABASE> -c "SELECT 'ALTER
'||quote_ident(n.nspname)||'.'||case when c.relkind='r' then 'TABLE' else
'SEQUENCE' END||' public.'||quote_ident(relname)||' OWNER TO <NEW_OWNER>;'
FROM pg_class c, pg_catalog.pg_namespace n
WHERE c.relkind IN ('r','S')
AND c.relnamespace=n.oid
AND n.nspname='<SCHEMA>';" | psql -qAt -d <DATABASE>
From | Date | Subject | |
---|---|---|---|
Next Message | Bob Lunney | 2011-06-24 21:21:36 | Parallel pg_dump on a single database |
Previous Message | Kevin Grittner | 2011-06-23 20:41:44 | Re: How to change all owners on all objects in a schema |