pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Spiegelberg <gspiegelberg@gmail.com>
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: Lance Campbell <lance@illinois.edu>
Cc: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: How to change all owners on all objects in a schema
Date: Thu, 23 Jun 2011 15:03:04 -0600
Message-ID: <BANLkTimHR07oOuqeUp-ix73tnxw8zbbL6w@mail.gmail.com> (raw)
In-Reply-To: <4E035EB8020000250003EB46@gw.wicourts.gov>
References: <B75CD08C73BD3543B97E4EF3964B7D70077BB4@CITESMBX2.ad.uillinois.edu>
	<4E035E20020000250003EB41@gw.wicourts.gov>
	<4E035EB8020000250003EB46@gw.wicourts.gov>

On Thu, Jun 23, 2011 at 2:41 PM, Kevin Grittner <Kevin.Grittner@wicourts.gov
> wrote:

> "Kevin Grittner" <Kevin.Grittner@wicourts.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>

view thread (4+ messages)

Message-ID: <BANLkTimHR07oOuqeUp-ix73tnxw8zbbL6w@mail.gmail.com>
Permalink:  ../BANLkTimHR07oOuqeUp-ix73tnxw8zbbL6w@mail.gmail.com/
Also on:    postgresql.org/message-id/BANLkTimHR07oOuqeUp-ix73tnxw8zbbL6w@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: gspiegelberg@gmail.com, Kevin.Grittner@wicourts.gov, lance@illinois.edu
  Subject: Re: How to change all owners on all objects in a schema
  In-Reply-To: <BANLkTimHR07oOuqeUp-ix73tnxw8zbbL6w@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox