Search code examples
sqlpostgresqlpgadmin

Get SQL code to generate the schema for an existing database in PostgreSQL


Given an existing database in PostgreSQL, I want to get the required SQL code to generate an identical database with no records.

Is there any easy way to do so?


Solution

  • You can use pg_dump command to do that. The option -s dumps only the schema and no data from the database.