Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 976
brewphone Avatar asked Oct 28 '25 14:10

brewphone


1 Answers

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

like image 115
Thirumal Avatar answered Oct 30 '25 14:10

Thirumal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!