Extracting DDL of Objects in PostgreSQL(get table ddl in PostgreSQL)

Extracting DDL of Objects in PostgreSQL(get table ddl in PostgreSQL)

===================================================


2 Ways to get DDL of objects in PostgreSQL


1. The utility pg_dump is used to dump the DDL.

2. Can get the DDL just by running \d.


1. The utility pg_dump is used to dump the DDL.


Table ddl for testtable from TESTDB

$ pg_dump -d TESTDB -s -t testtable

Table ddl for testtable from TESTDB written in to file ddl.sql

$ pg_dump -d TESTDB -s -T testtable -f ddl.sql

Table ddls for all ables from from TESTDB

$ pg_dump -d TESTDB -s


2. Can get the DDL just by running \d.

TESTDB=# \d+ testtable

No comments:

Post a Comment

View running queries in postgresql

 View running queries in postgreSQL: SELECT * FROM pg_stat_activity;