58 words
1 minute
Show the SQL schema for a PostgreSQL database
Anubhav Gain
2024-04-20

Show the SQL schema for a PostgreSQL database#

This took me longer to figure out than I care to admit.

pg_dump -s name-of-database

Surprisingly there doesn’t seem to be an easy way to do this using a SELECT statement within PostgreSQL itself.

StackOverflow offers up a terrifying 72 line SQL monstrosity that attempts to recreate the CREATE TABLE for a given table.

Show the SQL schema for a PostgreSQL database
https://mranv.pages.dev/posts/show-the-sql-schema-for-a-postgresql-database/
Author
Anubhav Gain
Published at
2024-04-20
License
CC BY-NC-SA 4.0