Monday, August 3, 2015

Owner of tables in postgresql

I though of re blogging this:

Although for some strange reason the particular table I want to know the owner does not appear in the list, yet all other ones do (oh, Murphy!)

select t.table_name, t.table_type, c.relname, c.relowner, u.usename
from information_schema.tables t
join pg_catalog.pg_class c on (t.table_name = c.relname)
join pg_catalog.pg_user u on (c.relowner = u.usesysid)
where t.table_schema='public';

No comments:

Post a Comment