Page 1 of 1
Who created a schema?
Posted: Tue Apr 22, 2014 3:35 pm
by sarah
Hi,
Per
viewtopic.php?f=3&t=1831 I now know when a schema was created, but how do I know who create it?
Re: Who created a schema?
Posted: Tue Apr 22, 2014 4:06 pm
by scutter
Hi Sarah,
You have the documentation? In the same SCHEMATA table:
Code: Select all
SCHEMA_OWNER VARCHAR Name of the owner who created the schema
—Sharon
Re: Who created a schema?
Posted: Tue Apr 22, 2014 4:32 pm
by sarah
Ok, sorry. I was thinking if the schema owner was changed, how would I know who created it. But we can't change a schema owner, so I guess this is a none issue
Code: Select all
dbadmin=> create user sarah;
CREATE USER
dbadmin=> create schema sarah;
CREATE SCHEMA
dbadmin=> select schema_owner from schemata where schema_name = 'sarah';
schema_owner
--------------
dbadmin
(1 row)
dbadmin=> alter schema sarah owner to sarah;
ERROR 2676: Command ALTER SCHEMA is not supported
Re: Who created a schema?
Posted: Thu Apr 24, 2014 2:13 pm
by JimKnicely
SCHEMA_OWNER VARCHAR Name of the owner who created the schema
That's not technically true when the "AUTHORIZATION" option is used on the CREATE SCHEMA command
Code: Select all
dbadmin=> create user jim;
CREATE USER
dbadmin=> create schema cowboy authorization jim;
CREATE SCHEMA
dbadmin=> select schema_owner, create_time from schemata where schema_name = 'cowboy';
schema_owner | create_time
--------------+-------------------------------
jim | 2014-04-24 09:05:46.588581-04
(1 row)
I created the
cowboy schema as the user
dbadmin, not the user
jim.