HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to dump only create table statements (or table definitions only) with pg_dump in Postgresql

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqldumppg_dumpcreatewithstatementshowonlytabledefinitions

Problem

I want only the table definitions, not wiews nor functions.

I have a schema named "cvp". I try:

pg_dump --schema-only -n cvp -t 'cvp.*' --format plain


And I get:

pg_dump: No matching tables were found


I try also without -n cvp or changing -t to -t . -t cvp.

I'am using PostgreSQL 11.

Solution

I've just tried this:

pg_dump -s -t test.* -d test


It nicely exported all table definitions, as expected. -s is the same as --schema-only.

Code Snippets

pg_dump -s -t test.* -d test

Context

StackExchange Database Administrators Q#250685, answer score: 3

Revisions (0)

No revisions yet.