1

Is there a way to generate the GRANT statements that have been run on a schema in PostgreSQL, for example if myUser has been granted usage on mySchema the script would generate

GRANT USAGE ON SCHEMA mySchema TO myUser;

1 Answer 1

2

Use pg_dump

pg_dump -d myDatabase --schema mySchema --section=pre-data |
  grep '^GRANT'

If you want just the GRANT on the schema object.

pg_dump -d myDatabase --schema mySchema --section=pre-data |
  grep '^GRANT .* ON SCHEMA .* TO'
1
  • 1
    Yup this does exactly what I need to to do! Thanks a ton!!
    – koye
    Oct 27, 2017 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.