Here is a link to the Redshift administrative scripts in the github repo amazon-redshift-utils
Here are a collection of AWS Redshift administration scripts which list the ownership of the objects.
Find ownership of views and tables#
SELECT n.nspname AS schema_name,
pg_get_userbyid(c.relowner) AS table_owner,
c.relowner,
c.relname AS table_name,
CASE
WHEN c.relkind = 'v' THEN 'view'
ELSE 'table'
END AS table_type,
d.description AS table_description
FROM pg_class As c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
LEFT JOIN pg_description As d ON (
d.objoid = c.oid
AND d.objsubid = 0
)
WHERE c.relkind IN('r', 'v')
AND c.relowner <> 1;
Find ownership of stored procedures#
SELECT n.nspname AS schema_name,
pg_get_userbyid(p.proowner) AS proc_owner,
p.proowner,
p.proname AS pro_name
FROM pg_proc As p
LEFT JOIN pg_namespace n ON n.oid = p.pronamespace
WHERE p.proowner <> 1;