Search code examples
postgresqlpg-dump

How to get a full list of schemas in pg_dump?


How can I get a full list of schemas in known database Postgresql in pg_dump utility to backup each schema in a separate file?

Now I use it in this way:

# pg_dump my_database

Solution

  • Try

    psql -c "select schema_name from information_schema.schemata" -At
    

    to return just the names, i.e., suitable for shell scripting.