Re: How to know and change the owner of a table in psql ?

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: David Pradier <dpradier(at)apartia(dot)fr>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to know and change the owner of a table in psql ?
Date: 2002-11-22 10:28:28
Message-ID: 1037960908.1046.47.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)Elphick(at)lfix(dot)co(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Goodenough 2002-11-22 11:27:05 Re: how do i find out when a record was created/modified?
Previous Message Oliver Elphick 2002-11-22 10:12:56 Re: how do i find out when a record was created/modified?