brewphone
brewphone

Reputation: 1366

Postgresql, export a sql file to create database

With MySql Workbench, I could create all tables of a database with EER-Diagram, and then do File/Export/Forward Engineer SQL Create Script to generate a sql file that creates the db plus all tables of the db. In Postgresql, with pgAdmin4 or DBeaver, I have created all tables under database/schema, is there any similar way to generate a sql file to create the db and all tables of the db?

Upvotes: 4

Views: 9831

Answers (1)

Thirumal
Thirumal

Reputation: 9656

You export only schema without data using pg_dump in psql [terminal]:

pg_dump -U postgres -s databasename > backup.sql

or with Pgadmin4

  1. Go to Tool -> Backup and select only schema in the Dump option.

Screenshot of Backup

Upvotes: 3

Related Questions