Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l0JnX-0003ms-OH for pgsql-general@arkaria.postgresql.org; Fri, 15 Jan 2021 07:45:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l0JnW-0004GT-8M for pgsql-general@arkaria.postgresql.org; Fri, 15 Jan 2021 07:45:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l0JnW-0004GL-0T for pgsql-general@lists.postgresql.org; Fri, 15 Jan 2021 07:45:30 +0000 Received: from portal-smtp-out.hot.ee ([194.126.101.125]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l0JnR-0006zL-1c for pgsql-general@postgresql.org; Fri, 15 Jan 2021 07:45:26 +0000 Received: from localhost (localhost [127.0.0.1]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 1C3D61DEF for ; Fri, 15 Jan 2021 09:45:23 +0200 (EET) X-Virus-Scanned: Debian amavisd-new at vm-hot-relay10.estpak.ee Received: from portal-smtp-out.hot.ee ([127.0.0.1]) by localhost (vm-hot-relay10.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jv98BaVNo5VY for ; Fri, 15 Jan 2021 09:45:20 +0200 (EET) Received: from mail.hot.ee (hot-relayhost3.estpak.ee [213.180.2.81]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id DC6621DE8 for ; Fri, 15 Jan 2021 09:45:20 +0200 (EET) To: pgsql-general@postgresql.org From: Andrus Subject: REASSIGN OWNED BY in current database only Message-ID: Date: Fri, 15 Jan 2021 09:45:15 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------6C1AD75A74FB7E045CBFDB80" Content-Language: et List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------6C1AD75A74FB7E045CBFDB80 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi! Cluster contains lot databases. All objects in database should owned by separate role  whose name is in form databasename_owner where databasename is this database name in cluster. This role in granted to cluster users who should have acces to this database. Database is restored  from other cluster where is has different name. After that REASSIGN OWNED BY originaldbname_owner TO restoreddbname_owner is used to force this role in restored database. This command changes also owner of global objects also. How to change  owner only in current database, leaving global objects owner unchanged ? Andrus. --------------6C1AD75A74FB7E045CBFDB80 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Hi!

Cluster contains lot databases.

All objects in database should owned by separate role  whose name is in form

databasename_owner

where databasename is this database name in cluster.

This role in granted to cluster users who should have acces to this database.

Database is restored  from other cluster where is has different name.

After that

REASSIGN OWNED BY originaldbname_owner TO restoreddbname_owner

is used to force this role in restored database.

This command changes also owner of global objects also.

How to change  owner only in current database, leaving global objects owner unchanged ?

Andrus.
--------------6C1AD75A74FB7E045CBFDB80--