Skip to content

Instantly share code, notes, and snippets.

@evbots
Created November 15, 2017 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evbots/8ac02b6cdd47dfba8d55d823ee8e75e2 to your computer and use it in GitHub Desktop.
Save evbots/8ac02b6cdd47dfba8d55d823ee8e75e2 to your computer and use it in GitHub Desktop.
SQL snippets
-- See all schemas and who their owners are and what access privileges are
SELECT n.nspname AS "Name",
pg_catalog.pg_get_userbyid(n.nspowner) AS "Owner",
pg_catalog.array_to_string(n.nspacl, E'\n') AS "Access privileges",
pg_catalog.obj_description(n.oid, 'pg_namespace') AS "Description"
FROM pg_catalog.pg_namespace n
WHERE n.nspname !~ '^pg_' AND n.nspname <> 'information_schema'
ORDER BY 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment