| From: | Devrim GUNDUZ <devrim(at)gunduz(dot)org> |
|---|---|
| To: | "Benjamin Thelen (CCGIS)" <thelen(at)ccgis(dot)de> |
| Cc: | pgsql-admin(at)postgresql(dot)org |
| Subject: | Re: changing ownership of db |
| Date: | 2003-07-29 17:23:10 |
| Message-ID: | Pine.LNX.4.44.0307291956570.17013-100000@emo.org.tr |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-admin |
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(at)gunduz(dot)org devrim(dot)gunduz(at)linux(dot)org(dot)tr
http://www.tdmsoft.com
http://www.gunduz.org
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2003-07-29 17:28:16 | Re: Postgres db corrupted ? |
| Previous Message | John P. Looney | 2003-07-29 17:06:43 | Re: Postgres db corrupted ? |