Skip site navigation (1) Skip section navigation (2)

Re: Change Ownership Recursively

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>
Cc: "PostgreSQL (SQL)" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Change Ownership Recursively
Date: 2012-03-01 18:36:17
Message-ID: 4F4FC1A1.6070702@gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
On 03/01/2012 09:04 AM, Carlos Mennens wrote:
> On Thu, Mar 1, 2012 at 11:38 AM, Eric Ndengang
> <eric(dot)ndengang_foyet(at)affinitas(dot)de>  wrote:
>> Hi
>> You can try this command "REASSIGN OWNED BY .... TO ..." like this:
>> REASSIGN OWNED BY previous_role TO new_role;
>>   DROP OWNED previous_role;
>
> I did as follows:
>
> iamunix=# \c postgres
> SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
> You are now connected to database "postgres" as user "carlos".

You are working on the database 'postgres' not 'iamunix'. REASSIGN works 
on the current database only. So you just REASSIGNED any objects in 
postgres.

> postgres=# REASSIGN OWNED BY carlos TO lauren;
> REASSIGN OWNED
> postgres=# DROP OWNED BY carlos;
> DROP OWNED
>
> iamunix=# \d
>                 List of relations
>   Schema |       Name       |   Type   | Owner
> --------+------------------+----------+--------
>   public | dept             | table    | carlos
>   public | dept_id_seq      | sequence | carlos
>   public | employees        | table    | carlos
>   public | employees_id_seq | sequence | carlos
>   public | manager_lookup   | view     | carlos
>   public | managers         | table    | carlos
>   public | managers_id_seq  | sequence | carlos

Change into iamunix and do the REASSIGN.

>
> That didn't work for some reason but mostly because I don't follow the
> concept of what's being done. I've now since changed the database role
> owner back to Carlos so now 'Carlos' owns both the database and all of
> it's tables. Can we start fresh and assume I just got the request to
> change the specified database and all of it's tables, sequences,
> views,&  triggers to Lauren?

See above. For future reference including the Postgres version would be 
helpful. This area ownership/grants/etc has undergone a lot of changes 
over the various versions.

>


-- 
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Responses

pgsql-sql by date

Next:From: Carlos MennensDate: 2012-03-01 19:37:16
Subject: Re: Change Ownership Recursively
Previous:From: F. BROUARD / SQLproDate: 2012-03-01 17:23:18
Subject: Re: Natural sort order

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group