Postgresql – pg_dump: Show GRANT Statements only

permissionspg-dumppostgresql

I executed this manually:

GRANT SELECT ON TABLE my_table TO some_user;

How can I dump this statement again?

I looked at pg_dumpd but only found a way to do a data-only dump or a schema-only dump.

If I do the following, then I get both (CREATE TABLE and GRANT statements)

pg_dump --schema-only -t my_table my_db

Is there a way to exclude the CREATE statements, and to show the GRANT statements only?

Best Answer

This should work,

pg_dump --section=pre-data -d myDb | grep -e '^\(GRANT\|REVOKE\)'