Monday, August 3, 2015

Owner of tables in postgresql

I though of re blogging this: http://cully.biz/2013/12/11/postgresql-getting-the-owner-of-tables/

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

cancel script completely on ctrl-c

I found this question interesting: basically how to cancel completely a script and all child processes : You do this by creating a subro...