From: Benjamin Thelen (CCGIS) <thelen@ccgis.de>
To: Devrim GUNDUZ <devrim@gunduz.org>
Cc: pgsql-admin@postgresql.org
Subject: Re: changing ownership of db
Date: Thu, 31 Jul 2003 18:42:33 +0200
Message-ID: <3F2946F9.3080505@ccgis.de> (raw)
In-Reply-To: <Pine.LNX.4.44.0307291956570.17013-100000@emo.org.tr>
References: <Pine.LNX.4.44.0307291956570.17013-100000@emo.org.tr>
Thanks very much!!
I had a user who was allowed to create dbs, but wasn't superuser...Now I
just have a superuser.
Benjamin
Devrim GUNDUZ wrote:
> 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,
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: thelen@ccgis.de, devrim@gunduz.org
Subject: Re: changing ownership of db
In-Reply-To: <3F2946F9.3080505@ccgis.de>
References: <Pine.LNX.4.44.0307291956570.17013-100000@emo.org.tr> <3F2946F9.3080505@ccgis.de>
* 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