Thread: ownership of DBs and tables?

ownership of DBs and tables?

From
Louis Bertrand
Date:
Is there a way of changing the ownership of tables and even entire
databases?

Here's why I ask. I created a database "webdb" for a PHP3 application and
created a database user "www" to own it. However, I am creating the actual
tables as user "louis" who has superuser privileges in PostgreSQL. When
I look at the ownership of a new table, it's "louis", not "www". I'm
doing this with psql and pgaccess. I'd rather not have to su(8) as
"www" to perform DB maintenance.

Thanks
 --Louis  <louis@bertrandtech.on.ca>

Louis Bertrand       http://www.bertrandtech.on.ca/
Bertrand Technical Services, Bowmanville, ON, Canada

OpenBSD: Secure by default.  http://www.openbsd.org/



Re: [GENERAL] ownership of DBs and tables?

From
Jim Richards
Date:
At 09:58 PM 16/02/00 -0500, you wrote:
>Is there a way of changing the ownership of tables and even entire
>databases?

Um, after the table has been created no, but you can set up users and
accounts, so as you, try (in ksh, not sure about others)

    PGUSER=postgres PGPASSWORD=postgres psql template1

then

    create user www with password "www";

then when you want to run scripts, or connect then you can with

    PGUSER=www PGPASSSWORD=www psql -f filename.sql webdb

or interactively

    PGUSER=www PGPASSSWORD=www psql webdb

    >\i filename.sql

>Here's why I ask. I created a database "webdb" for a PHP3 application and
>created a database user "www" to own it. However, I am creating the actual
>tables as user "louis" who has superuser privileges in PostgreSQL. When
>I look at the ownership of a new table, it's "louis", not "www". I'm
>doing this with psql and pgaccess. I'd rather not have to su(8) as
>"www" to perform DB maintenance.



--
 An army marches as fast as its slowest stomach.
  Mr Grumpy - what are you on about?
    http://www.cyber4.org/members/grumpy/index.html


Re: [GENERAL] ownership of DBs and tables?

From
Louis Bertrand
Date:
Ah, that makes a lot of sense. The line separating UNIX users and
PostgreSQL users was obviously fuzzy in my mind (as are many things).

Thanks
 --Louis  <louis@bertrandtech.on.ca>

Louis Bertrand       http://www.bertrandtech.on.ca/
Bertrand Technical Services, Bowmanville, ON, Canada

OpenBSD: Secure by default.  http://www.openbsd.org/

On Thu, 17 Feb 2000, Jim Richards wrote:

> At 09:58 PM 16/02/00 -0500, you wrote:
> >Is there a way of changing the ownership of tables and even entire
> >databases?
>
> Um, after the table has been created no, but you can set up users and
> accounts, so as you, try (in ksh, not sure about others)
>
>     PGUSER=postgres PGPASSWORD=postgres psql template1
>
> then
>
>     create user www with password "www";
>
> then when you want to run scripts, or connect then you can with
>
>     PGUSER=www PGPASSSWORD=www psql -f filename.sql webdb
>
> or interactively
>
>     PGUSER=www PGPASSSWORD=www psql webdb
>
>     >\i filename.sql
>
> >Here's why I ask. I created a database "webdb" for a PHP3 application and
> >created a database user "www" to own it. However, I am creating the actual
> >tables as user "louis" who has superuser privileges in PostgreSQL. When
> >I look at the ownership of a new table, it's "louis", not "www". I'm
> >doing this with psql and pgaccess. I'd rather not have to su(8) as
> >"www" to perform DB maintenance.
>
>
>
> --
>  An army marches as fast as its slowest stomach.
>   Mr Grumpy - what are you on about?
>     http://www.cyber4.org/members/grumpy/index.html
>
>
> ************
>
>
>



Re: [GENERAL] ownership of DBs and tables?

From
Karl DeBisschop
Date:
>>Is there a way of changing the ownership of tables and even entire
>>databases?
>
>Um, after the table has been created no, but you can set up users and
>accounts, so as you, try (in ksh, not sure about others)

Um, if you are a superuser:

UPDATE pg_class SET relowner=<newowner> where relmane=<table>;

I don't think databases have owners - or at least owner is not listed
in the pg_database table.

--
Karl DeBisschop <kdebisschop@alert.infoplease.com>
617.832.0332 (Fax: 617.956.2696)

Information Please - your source for FREE online reference
http://www.infoplease.com  - Your Ultimate Fact Finder
http://kids.infoplease.com - The Great Homework Helper

Netsaint Plugins Development
http://netsaintplug.sourceforge.net

Re: [GENERAL] ownership of DBs and tables?

From
Louis Bertrand
Date:
Yeah, I've looked at the system tables but they look scary. Without proper
documentation I'm not keen on mucking around with them. I noticed pg_class
appears to have the owner of the table (relowner).

Thanks
 --Louis  <louis@bertrandtech.on.ca>

Louis Bertrand       http://www.bertrandtech.on.ca/
Bertrand Technical Services, Bowmanville, ON, Canada

OpenBSD: Secure by default.  http://www.openbsd.org/

On Wed, 16 Feb 2000, Karl DeBisschop wrote:

>
> >>Is there a way of changing the ownership of tables and even entire
> >>databases?
> >
> >Um, after the table has been created no, but you can set up users and
> >accounts, so as you, try (in ksh, not sure about others)
>
> Um, if you are a superuser:
>
> UPDATE pg_class SET relowner=<newowner> where relmane=<table>;
>
> I don't think databases have owners - or at least owner is not listed
> in the pg_database table.
>
> --
> Karl DeBisschop <kdebisschop@alert.infoplease.com>
> 617.832.0332 (Fax: 617.956.2696)
>
> Information Please - your source for FREE online reference
> http://www.infoplease.com  - Your Ultimate Fact Finder
> http://kids.infoplease.com - The Great Homework Helper
>
> Netsaint Plugins Development
> http://netsaintplug.sourceforge.net
>
>