Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export a CREATE script for a database

Say I've created a database in pgAdmin, but I want to export a CREATE sql file.

How would I go about generating the dump?

like image 421
serv-bot 22 Avatar asked May 16 '11 22:05

serv-bot 22


People also ask

How do you create a database script?

Open SQL Server Management Studio. In the Object Explorer, expand Databases, and then locate the database that you want to script. Right-click the database, point to Tasks, and then click Generate Scripts. In the Script Wizard, verify that the correct database is selected.


1 Answers

Here's how to use pgAdmin to create a schema script that can be used with a PostgreSql database schema comparison tool such as apgdiff. These instructions are for pgAdmin3.

  1. In pgAdmin, right click on the database and click Backup.
  2. Enter an appropriate path and filename (i.e. /some/path/my_script.sql).
  3. Select Plain as the format in the format dropdown.
  4. Go to the Dump Options #1 tab and check "Only schema".
  5. Then click Backup. Then click Done.

Note: Yes, I realize that pgAdmin uses pg_dump behind the scenes to create the script, but the question was about pgAdmin, so this is the GUI method.

like image 120
Nate Cook Avatar answered Sep 27 '22 23:09

Nate Cook