Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a PostgreSQL table owner?

Tags:

postgresql

I am unsure about what does a PostgreSQL table owner means. I notice that it changes an attribute of the table itself and not about the owner because it is specified through an

ALTER TABLE table_name OWNER TO role_name; 
like image 516
Jonathan Ginsburg Avatar asked Nov 21 '15 09:11

Jonathan Ginsburg


People also ask

How do I find out who owns a table?

I can find the owner of a table using : Select owner from dba_tables where table_name = 'name_of_table_to_search';

How do I find the owner of a Postgres database?

You can use current_database() if you need to dynamically find out which database you are connected to and which owner you are interested in. You can remove the where clause to get owners of all databases in the current cluster.

Can Postgres table have multiple owners?

No, each database can only have one owner. As stated previously you can have more than one superuser, or you can grant permissions specifically to group roles that are then inherited.

Can we change the owner of table in PostgreSQL?

You must own the table to use ALTER TABLE. To change the schema of a table, you must also have CREATE privilege on the new schema. To alter the owner, you must also be a direct or indirect member of the new owning role, and that role must have CREATE privilege on the table's schema.


1 Answers

You can see who is owner in certain table:

select * from pg_tables where tablename = 'my_tbl'; 

or you can see all tables by certain owner:

select * from pg_tables where tableowner = 'username'; 
like image 102
Scirocco Avatar answered Sep 21 '22 07:09

Scirocco