Export a CREATE script for the database from pgAdmin

Say I created a database in pgAdmin, but I want to export the CREATE SQL file.

How can I create a dump?

+50
sql database postgresql pgadmin
May 16 '11 at 22:19
source share
5 answers

To create a sql script that will create tables as they exist in this database, follow these steps:

pg_dump --schema-only --no-owner the_database > create_the_tables.sql

This will give you a bunch of create table instructions. To see how portable I tried the following:

 bvm$ pg_dump -s --no-owner devdb | sqlite3 so_ans.db 

And then:

 bvm$ sqlite3 so_ans.db .schema CREATE TABLE courses ( id integer NOT NULL, name text, created_by integer, jc text ); 

Kind of cool.

+38
May 17 '11 at 2:39
source share

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

  • In pgAdmin, right-click on the database and select "Backup".
  • Enter the appropriate path and file name (i.e. /some/path/my_script.sql ).
  • Select Plain as the format from the drop-down list.
  • Go to the "Dump Parameters No. 1 " tab and check the "Scheme only" box.
  • Then click "Backup." Then click Finish.

Note: Yes, I understand that pgAdmin uses pg_dump backstage to create a script, but the question was about pgAdmin, so this is a GUI method.

+81
Mar 01 '13 at 16:29
source share

pgAdmin, however, has the ability to do what you want:

Right-click the database you want to export

Select "Backup" from the popup menu

Choose "format" Normal.

Select the "simple option" Scheme only

+22
Apr 14 '14 at 10:11
source share

You can achieve this via phpPgAdmin just like phpMyAdmin for MySQL.

Log in to phpPgAdmin, select the database, and then select export.

+3
Dec 19 '12 at 10:52
source share

At least in PgAdmin III 1.22.1 you can get a CREATE script: 1) right-click the table name 2) "Scripts" → "CREATE script" There are options for getting SELECT, DELETE, etc.

-one
Sep 21 '16 at 14:17
source share



All Articles