Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create sql script of postgres database schema?

Tags:

I want sql script of postgres 9 database schema which is not on local server. I tried pg_dump command on sql editor of pgAdmin and its not working there. I m not sure where to run that command. Please assist me with the same.... Thanks..

like image 437
DMS Avatar asked Oct 18 '11 08:10

DMS


People also ask

How do I create a schema script in PostgreSQL?

To generate SQL scripts from your PostgreSQL project click the SQL Script icon on the main toolbar. New modal opens. Click Save Script and select a location where the file should be stored. Option Overwrite existing files allows you to ignore existing scripts and overwrite them without getting a warning.

How do I run a SQL script in PostgreSQL?

Another easiest and most used way to run any SQL file in PostgreSQL is via its SQL shell. Open the SQL shell from the menu bar of Windows 10. Add your server name, database name where you want to import the file, the port number you are currently active on, PostgreSQL username, and password to start using SQL shell.


1 Answers

pg_dump is a command line utility; it isn't SQL, so it won't work in pgAdmin or anywhere else that executes SQL.

pgAdmin however does have a facility to do what you want:

  1. Right-click on the database you want to export
  2. Select Backup from the pop-up menu
  3. Chose "format" Plain
  4. Chose "plain option" Only schema
like image 59
Bohemian Avatar answered Sep 20 '22 15:09

Bohemian