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 9C957D1C4B9 for ; Tue, 29 Jul 2003 17:23: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 84646-03 for ; Tue, 29 Jul 2003 14:22:21 -0300 (ADT) Received: from emo.org.tr (emo.org.tr [195.142.105.9]) by svr1.postgresql.org (Postfix) with ESMTP id E4E69D1C4B7 for ; Tue, 29 Jul 2003 14:23:17 -0300 (ADT) Received: from localhost (emo.org.tr [127.0.0.1]) by emo.org.tr (8.11.6/8.11.6) with ESMTP id h6THNAh22989; Tue, 29 Jul 2003 20:23:10 +0300 Date: Tue, 29 Jul 2003 20:23:10 +0300 (EEST) From: Devrim GUNDUZ X-X-Sender: devrim2@emo.org.tr To: "Benjamin Thelen (CCGIS)" Cc: pgsql-admin@postgresql.org Subject: Re: changing ownership of db In-Reply-To: <3F26A721.4020100@ccgis.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/292 X-Sequence-Number: 9632 Hi, On Tue, 29 Jul 2003, Benjamin Thelen (CCGIS) wrote: > I would like to change the ownership of a database. The only thing I > could find up to now, is that it is difficult, but I couldn't find any > detailed help. Connect to that database via psql. Then, first, update pg_database: UPDATE pg_database SET datdba=(SELECT usesysid FROM pg_shadow WHERE usename='new_owner') WHERE datname='db_name'; 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_%'); Maybe there is a shorter way, but I know this one. HTH, Regards, -- Devrim GUNDUZ devrim@gunduz.org devrim.gunduz@linux.org.tr http://www.tdmsoft.com http://www.gunduz.org