0

With pgAdmin, on my created DB, I have seven tables (all of them have at least one primary key, and some of them include foreign keys). Let's suppose in a moment I need to do a mayor correction so I don't have no other choice that to move it to another DB, and I don't want to rewrite the characteristics of the seven tables over and over again.

So, with that said, how I can export my tables (the structure, not the data), so, when I create another DB with pgAdmin, I can import my tables previously created.

SealCuadrado
  • 749
  • 1
  • 10
  • 21

2 Answers2

1
create table new (
    like old
    including defaults
    including constraints
    including indexes
);

REF Copy table structure into new table

Community
  • 1
  • 1
varun
  • 4,522
  • 33
  • 28
  • I read the reference, and it doesn't work form me because at least half of the tables have foreign keys. – SealCuadrado Jun 11 '13 at 18:59
  • in that case you gotta do some extra work.. read this http://stackoverflow.com/questions/5359968/restore-postgresql-db-from-backup-without-foreign-key-constraint-issue – varun Jun 11 '13 at 19:01
1

With pgAdmin 1.14 and prior releases, there were only two ways to insert data in a table: use the restore tool (which uses pg_restore) ; use the query tool to execute INSERT queries (COPY queries are allowed if they use a file, but not stdin/stdout). This link would help you

Sunil B N
  • 4,159
  • 1
  • 31
  • 52