Created
May 24, 2019 20:58
-
-
Save mccurdyc/5400d790b6724a983a2d77a91e6a748a to your computer and use it in GitHub Desktop.
Find the Owner of a Table Postgres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select datname,dbid,objid,refclassid,refobjid,deptype,rolname, nspname || '.' || relname as objname, relowner, nspname || '.' || proname as funcname, proowner | |
from pg_shdepend | |
left join pg_roles on (pg_shdepend.refobjid = pg_roles.oid) | |
left join pg_database on (pg_shdepend.dbid = pg_database.oid) | |
left join pg_class on (pg_class.oid = pg_shdepend.objid) | |
left join pg_proc on (pg_proc.oid = pg_shdepend.objid) | |
left join pg_namespace on (pg_namespace.oid in (pg_class.relnamespace, pg_proc.pronamespace)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment