Thread: Object ownership in a new database

Object ownership in a new database

From
Russell Smith
Date:
Hello all,

When you create a new database, not all objects in that database are
owned by the database owner.  Now some of those may need to be owned by
a superuser, eg C functions.  However should other things such as the
public schema or other general objects be owned by the database owner,
or the user who created them in the template database?

To create a db with the public schema owned by postgres, just:

$ createdb -h 172.17.72.1 -U postgres -O non_superuser owner_test;

$ psql -h 172.17.72.1 -U postgres owner_test;
owner_test=# \dn
         List of schemas
         Name        |  Owner
--------------------+----------
  information_schema | postgres
  pg_catalog         | postgres
  pg_toast           | postgres
  public             | postgres
(4 rows)

owner_test=# \q


Now everything is owned by postgres.

Is this the correct and desired behaviour, or is the behaviour expected
to be different.  I expected it to be owned by "non_superuser".

Any comments welcome.

Russell Smith