pg_dump --schema-only mydb > schema.sql

Category: Databases & SQL

pg_dump --schema-only mydb > schema.sql

Back up table structure without data

Writes only DDL (data definition language) — tables, indexes, constraints, functions — with no rows, perfect for migration scripts or cloning an empty schema. The counterpart --data-only dumps rows without structure. Related: psql -f to apply it.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.