Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a similar vein to this question, how would I do a schema-only dump in PostgreSQL?

share|improve this question
up vote 28 down vote accepted

pg_dump --schema-only

share|improve this answer
easier than I realized it would be :) – warren Aug 31 '09 at 4:22
Frankly, I haven't much clue about postgres administration, but I've been watching videos from pgcon 09 and someone mentioned pg_dump. – jldugger Aug 31 '09 at 4:27
either way - it's what I needed :) – warren Sep 7 '09 at 13:41
@warren: it's even easier: pg_dump -s. – hans0l0 Nov 20 '13 at 14:58

If you only want the create tables, then you can do pg_dump -s databasename | awk 'RS="";/CREATE TABLE[^;]*;/'

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.