DDL for database creation

Started by Julie Nishimuraabout 7 years ago4 messagesgeneral
Jump to latest
#1Julie Nishimura
juliezain@hotmail.com

Hello psql friends,
Is there a way to reconstruct DDL for creation of existing databases? For example, I need to create dev environment for some (not all) of our existing databases, and I would like to keep the same encoding, connection limit (if anything was specified), etc. Is there a way to create this DDL?

Thank you!

#2Bruce Momjian
bruce@momjian.us
In reply to: Julie Nishimura (#1)
Re: DDL for database creation

On Sat, Mar 9, 2019 at 02:13:57AM +0000, Julie Nishimura wrote:

Hello psql friends,
Is there a way to reconstruct DDL for creation of existing databases? For
example, I need to create dev environment for some (not all) of our existing
databases, and I would like to keep the same encoding, connection limit (if
anything was specified), etc. Is there a way to create this DDL?

pg_dump --schema-only maybe?

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#2)
Re: DDL for database creation

Bruce Momjian <bruce@momjian.us> writes:

On Sat, Mar 9, 2019 at 02:13:57AM +0000, Julie Nishimura wrote:

Is there a way to reconstruct DDL for creation of existing databases? For
example, I need to create dev environment for some (not all) of our existing
databases, and I would like to keep the same encoding, connection limit (if
anything was specified), etc. Is there a way to create this DDL?

pg_dump --schema-only maybe?

The specific settings the OP mentions are database-level settings;
so she'd need pg_dumpall (perhaps with -g), or pg_dump with -C.

regards, tom lane

#4Ron
ronljohnsonjr@gmail.com
In reply to: Tom Lane (#3)
Re: DDL for database creation

On 3/8/19 9:20 PM, Tom Lane wrote:

Bruce Momjian <bruce@momjian.us> writes:

On Sat, Mar 9, 2019 at 02:13:57AM +0000, Julie Nishimura wrote:

Is there a way to reconstruct DDL for creation of existing databases? For
example, I need to create dev environment for some (not all) of our existing
databases, and I would like to keep the same encoding, connection limit (if
anything was specified), etc. Is there a way to create this DDL?

pg_dump --schema-only maybe?

The specific settings the OP mentions are database-level settings;
so she'd need pg_dumpall (perhaps with -g), or pg_dump with -C.

Why not "pg_dumpall --schema-only" in combination with "pg_dumpall -g"?

https://www.postgresql.org/docs/9.6/app-pg-dumpall.html
-s
--schema-only
    Dump only the object definitions (schema), not data.

--
Angular momentum makes the world go 'round.