pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rudi <rudi@oasis.net.au>
To: pgsql-sql@postgresql.org
Subject: Re: Database ownership
Date: Wed, 6 Feb 2002 08:49:05 +1000
Message-ID: <006d01c1ae97$50994040$0c00a8c0@sun> (raw)
References: <002601c1adf5$24a37750$0c00a8c0@dev1>
	<20020205152230.GB23826@media-support.de>

Michael,
Thank you kindly - exactly what I was after.
Cheers
Rudi.

----- Original Message -----
From: "Michael Lamertz" <mlamertz@media-support.de>
To: "Rudi" <rudi@oasis.net.au>
Cc: <pgsql-sql@postgresql.org>
Sent: Wednesday, February 06, 2002 1:22 AM
Subject: Re: [SQL] Database ownership


> On Tue, Feb 05, 2002 at 01:28:12PM +1000, Rudi wrote:
> > Hi,
> >
> > I've been searching without any joy so far so I thought I'd ask.
> > Can I change the ownership of a database after the database is created ?
> > Or do I need to drop the database and recreate it using the new database
owner account ?
>
> Nope,
>
> \d pg_database and pg_shadow.  pg_database.datdba is a reference to
> pg_shadow.usesysid.
>
> Find out who's the owner:
>     select a.datname, b.usename from pg_database a, pg_shadow b
>         where a.datdba = b.usesysid;
>
> Update the owner:
>     update pg_database
>         set datdba = (select usesysid from pg_shadow where usename =
'SOMEUSERHERE')
>         where datname = 'SOMEDATABASEHERE';
>
> That should do the trick.
>
> --
> Michael Lamertz        |
mike@lamertz.net
>     Nordstr. 49        |     http://www.lamertz.net -
http://www.perl-ronin.de
>     50733 Cologne      |                               Priv:    +49 221
445420
>     Germany            |                             Mobile:  +49 171 6900
310




view thread (2+ messages)

Message-ID: <006d01c1ae97$50994040$0c00a8c0@sun>
Permalink:  ../006d01c1ae97$50994040$0c00a8c0@sun/
Also on:    postgresql.org/message-id/006d01c1ae97$50994040$0c00a8c0@sun

 · 

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-sql@postgresql.org
  Cc: rudi@oasis.net.au
  Subject: Re: Database ownership
  In-Reply-To: <006d01c1ae97$50994040$0c00a8c0@sun>

* 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