X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E51BBD1C975 for ; Tue, 29 Jul 2003 21:41:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 01557-04 for ; Tue, 29 Jul 2003 18:40:22 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 029FCD1C93F for ; Tue, 29 Jul 2003 18:41:18 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h6TLf8Q3004648; Tue, 29 Jul 2003 17:41:08 -0400 (EDT) To: Devrim GUNDUZ Cc: "Benjamin Thelen (CCGIS)" , pgsql-admin@postgresql.org Subject: Re: changing ownership of db In-reply-to: References: Comments: In-reply-to Devrim GUNDUZ message dated "Tue, 29 Jul 2003 20:23:10 +0300" Date: Tue, 29 Jul 2003 17:41:08 -0400 Message-ID: <4647.1059514868@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/302 X-Sequence-Number: 9642 Devrim GUNDUZ writes: > On Tue, 29 Jul 2003, Benjamin Thelen (CCGIS) wrote: >> I would like to change the ownership of a database. > UPDATE pg_database SET datdba=(SELECT usesysid FROM pg_shadow WHERE > usename='new_owner') WHERE datname='db_name'; That is all you need to do --- it's the only place CREATE DATABASE records the owner's identity. > If you also want to change the owner of the tables, update pg_class: > UPDATE pg_class SET relowner=(SELECT usesysid FROM pg_shadow WHERE > usename='new_owner') WHERE relname IN (SELECT relname from > pg_class WHERE relname NOT LIKE 'pg_%'); This is likely to be a very bad idea, especially if you give ownership of the system tables to a non-superuser. Ownership of those tables stays with the postgres user during a CREATE DATABASE. regards, tom lane