sql >> Base de Datos >  >> RDS >> PostgreSQL

Generar DDL programáticamente en Postgresql

Usa pg_dump con estas opciones:

pg_dump -U user_name -h host database -s -t table_or_view_names -f table_or_view_names.sql

Descripción:

-s or --schema-only : Dump only ddl / the object definitions (schema), without data.
-t or --table Dump :  Dump only tables (or views or sequences) matching table

Ejemplos:

-- dump each ddl table elon build.
$ pg_dump -U elon -h localhost -s -t spacex -t tesla -t solarcity -t boring > companies.sql

Lo siento si fuera de tema. Solo quiero ayudar a quien buscó en Google "psql dump ddl" y obtuvo este hilo.