Re: How to know and change the owner of a table in psql ? - Mailing list pgsql-general

From Oliver Elphick
Subject Re: How to know and change the owner of a table in psql ?
Date
Msg-id 1037960908.1046.47.camel@linda
Whole thread Raw
In response to How to know and change the owner of a table in psql ?  (David Pradier <dpradier@apartia.fr>)
List pgsql-general
On Fri, 2002-11-22 at 09:55, David Pradier wrote:
> Hi
>
> I'd like to know who's the owner of a table, and if i can change simply the
> owner of a table.
>
> I tried \z in psql, it gives me :
> {=,user1=arwdRxt,user2=arwdRxt}
>
> Does this mean that user1 is the owner ?

No, those are the granted permissions.

For the owner:

  SELECT   u.usename
    FROM   pg_class AS c,
           pg_user AS u
   WHERE   u.usesysid = c.relowner AND
           c.relname = 'tablename';

For 7.3, the last part of the condition would be:

           c.oid = 'tablename'::regclass;

to distinguish between similarly named tables in different schemas.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK
http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Can two walk together, except they be agreed?"
                                     Amos 3:3


pgsql-general by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: how do i find out when a record was created/modified?
Next
From: David Goodenough
Date:
Subject: Re: how do i find out when a record was created/modified?