3

In PostgreSQL, there is no SHOW CREATE statement, known for example from MySQL. But when you use the pgAdmin III client program and go to object details, you see the corresponding CREATE statement.

So here is my question:
How does pgAdmin III build the CREATE statements it shows? Does it use psql's \d command or some completely different PostreSQL API? If so, how can I use it?

Erwin Brandstetter
186k28 gold badges463 silver badges636 bronze badges
asked Feb 2, 2012 at 21:38

2 Answers 2

5

pgadmin has it's own reverse-engineering functionality - it just examines the system tables like pg_class and pg_attribute to find the details.

If what you're looking for is actually an easy way to show the CREATE statements for your objects that you can use from something else, you should look at pg_dump instead of pgadmin, it is much simpler. In particular, if you just want to look at it for one or more object, you can use pg_dump -s -t tablename and it will give you the required CREATE statements.

answered Feb 3, 2012 at 8:19
0

As far as I know pgAdmin runs SQL queries on the system catalogs to assemble the details of the table definition. Based on that information it "re-creates" the CREATE TABLE statement.

answered Feb 2, 2012 at 22:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.