Thread

  1. R: change owner on a table

    Marco DI NARDO <m.dinardo@gruppodigito.com> — 2001-01-25T19:46:50Z

    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
    
    -----Messaggio originale-----
    Da:	D. Duccini [SMTP:duccini@backpack.com]
    Inviato:	giovedi 25 gennaio 2001 18.11
    A:	Pgsql-novice
    Oggetto:	[NOVICE] change owner on a table
    
    
    i've got a table that was created by one user in a database, and i want to
    change the owner to another
    
    is there a straightforward way to do this?  or do i gotta hack the system
    tables ??
    
    
    -----------------------------------------------------------------------------
    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!"   
    -----------------------------------------------------------------------------
    
    
    
  2. Re: R: change owner on a table

    Francisco Reyes <fran@reyes.somos.net> — 2001-01-27T04:15:09Z

    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>;
    
    
    
  3. Re: R: change owner on a table

    D. Duccini <duccini@backpack.com> — 2001-01-27T18:14:13Z

    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!"   
    -----------------------------------------------------------------------------