Re: R: change owner on a table

From: "D(dot) Duccini" <duccini(at)backpack(dot)com>
To: Francisco Reyes <fran(at)reyes(dot)somos(dot)net>
Cc: Marco DI NARDO <m(dot)dinardo(at)gruppodigito(dot)com>, Pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: R: change owner on a table
Date: 2001-01-27 18:14:13
Message-ID: Pine.GSO.4.03.10101271207300.1598-100000@ra.bpsi.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


here's what i did (background methodology for future reference):

1. first i started psql -E to have it reveal the backend queries

This is really a useful way to discover where/how information is
stored/related in postgres via the console commands

2. I issued a \dt on the command to get the list of tables

team=> \dt
QUERY: SELECT usename, relname, relkind, relhasrules FROM pg_class, pg_user WHERE usesysid = relowner and ( relkind = 'r') and relname !~ '^pg_' ORDER BY relname

you'll see that it joins on usesysid = relowner, so all you need to do is
determine the usesysid of the new owner you want to own the table

3. select usesysid from pg_user where usename = 'newowner';

4. update pg_class set relowner = USESYSID WHERE relname =
'tableToUpdate';

where USESYID is the user id returned from above query in step 3

5. pat yourself on the back for being clever (no one else in your org will ;)

-duck

> On Thu, 25 Jan 2001, Marco DI NARDO wrote:
>
> > I've a problem is quite the same.
> > i've got a table that was created by one user in a database (me), and I want to
> > grant to other postgres user the right to view or update this table.
> > Marco
> > m(dot)dinardo(at)gruppodigito(dot)com
>
> I thought this is what the "grant" command is.
> I don't recall the exact syntax but it is something like:
> grant all to <user> on <table>;
>

-----------------------------------------------------------------------------
david(at)backpack(dot)com BackPack Software, Inc. www.backpack.com
+1 651.645.7550 voice "Life is an Adventure.
+1 651.645.9798 fax Don't forget your BackPack!"
-----------------------------------------------------------------------------

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2001-01-27 19:53:19 Re: Still lockin up...
Previous Message Herbie Pabst 2001-01-27 13:17:01 Still lockin up...