From: Devrim GUNDUZ <devrim@gunduz.org>
To: Benjamin Thelen (CCGIS) <thelen@ccgis.de>
Cc: pgsql-admin@postgresql.org
Subject: Re: changing ownership of db
Date: Tue, 29 Jul 2003 20:23:10 +0300 (EEST)
Message-ID: <Pine.LNX.4.44.0307291956570.17013-100000@emo.org.tr> (raw)
In-Reply-To: <3F26A721.4020100@ccgis.de>
Hi,
On Tue, 29 Jul 2003, Benjamin Thelen (CCGIS) wrote:
> I would like to change the ownership of a database. The only thing I
> could find up to now, is that it is difficult, but I couldn't find any
> detailed help.
Connect to that database via psql.
Then, first, update pg_database:
UPDATE pg_database SET datdba=(SELECT usesysid FROM pg_shadow WHERE
usename='new_owner') WHERE datname='db_name';
If you also want to change the owner of the tables, update pg_class:
UPDATE pg_class SET relowner=(SELECT usesysid FROM pg_shadow WHERE
usename='new_owner') WHERE relname IN (SELECT relname from
pg_class WHERE relname NOT LIKE 'pg_%');
Maybe there is a shorter way, but I know this one.
HTH,
Regards,
--
Devrim GUNDUZ
devrim@gunduz.org devrim.gunduz@linux.org.tr
http://www.tdmsoft.comhttp://www.gunduz.org
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: devrim@gunduz.org, thelen@ccgis.de
Subject: Re: changing ownership of db
In-Reply-To: <Pine.LNX.4.44.0307291956570.17013-100000@emo.org.tr>
References: <3F26A721.4020100@ccgis.de> <Pine.LNX.4.44.0307291956570.17013-100000@emo.org.tr>
* 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