Re: R: change owner on a table

D. Duccini <duccini@backpack.com>

From: "D. Duccini" <duccini@backpack.com>
To: Francisco Reyes <fran@reyes.somos.net>
Cc: Marco DI NARDO <m.dinardo@gruppodigito.com>, Pgsql-novice <pgsql-novice@postgresql.org>
Date: 2001-01-27T18:14:13Z
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.dinardo@gruppodigito.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@backpack.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!"   
-----------------------------------------------------------------------------