Re: refactoring a database owner without "reassign owned"

From: Vincent Veyron <vv(dot)lists(at)wanadoo(dot)fr>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: refactoring a database owner without "reassign owned"
Date: 2013-05-13 16:13:08
Message-ID: 1368461588.2563.49.camel@asus-1001PX.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Le mercredi 08 mai 2013 à 14:11 -0700, Jeff Janes a écrit :
> Let's say you have a database which is owned (as well as all the
> contents within it) by the postgres internal user.
>
>
> Having created or inherited a mess, how do you fix it?
>

with sed on Linux/Unix, you could do this :

pg_dump -f mess.out mess

sed -i 's/OWNER TO postgres/OWNER TO proper_username/' mess.out

createdb clean

psql -f mess.out clean

You'll also want to modify the REVOKE ALL ON SCHEMA/GRANT ALL ON SCHEMA
that are at the end of the dump file

--
Salutations, Vincent Veyron
http://marica.fr/site/demonstration
Logiciel de gestion des contentieux juridiques et des sinistres d'assurance

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jerry Sievers 2013-05-13 16:56:03 Re: Re: [GENERAL] pg_upgrade fails, "mismatch of relation OID" - 9.1.9 to 9.2.4
Previous Message Scott Marlowe 2013-05-13 15:11:49 Re: Vacuum problem