-
-
Save rafaelverger/8776442e59fa9682bd50a47cde9763f8 to your computer and use it in GitHub Desktop.
Redshift - view table/schema dependencies
This file contains hidden or 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
CREATE OR REPLACE VIEW dbo.vwdependencies | |
AS | |
SELECT DISTINCT c_p.oid AS tbloid | |
,n_p.nspname AS schemaname | |
,c_p.relname AS NAME | |
,n_c.nspname AS refbyschemaname | |
,c_c.relname AS refbyname | |
,c_c.oid AS viewoid | |
FROM pg_class c_p | |
JOIN pg_depend d_p ON c_p.relfilenode = d_p.refobjid | |
JOIN pg_depend d_c ON d_p.objid = d_c.objid | |
JOIN pg_class c_c ON d_c.refobjid = c_c.relfilenode | |
LEFT JOIN pg_namespace n_p ON c_p.relnamespace = n_p.oid | |
LEFT JOIN pg_namespace n_c ON c_c.relnamespace = n_c.oid | |
WHERE d_c.deptype = 'i'::"char" | |
AND c_c.relkind = 'v'::"char" | |
/* AND lower(name) = 'table_name' */ | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment