Обсуждение: copy table

Поиск
Список
Период
Сортировка

copy table

От
Marc Fromm
Дата:

I created a new database and I want to copy a table from a different database into the new database.

1. I used phpPgAdmin and exported the table that I want a copy of.

2. In the new database I pasted the export into the SQL box in phpPgAdmin and clicked execute to create the table.

The table was created with no errors

The only problem is it did not create the sequence for the primary key.

 

Do I have to manually create the sequence or did I miss a step in exporting and creating the table?

 

 

Thanks

 

Marc

 

Re: copy table

От
"Melissa Peterson"
Дата:

For your primary key column, does the SQL in your table creation script look like:

column_name integer NOT NULL DEFAULT nextval('rd."table_name_columname_seq"'::regclass)

or

column_name serial

If the former, and if your original sequence wasn't anything custom, try changing it to "column_name serial" (or bigserial, depending on your needs).

Melissa Peterson
R&D Engineer
melissa@gigacrete.com
GigaCrete, Inc.
6775 Speedway Boulevard, Suite M-104
Las Vegas, NV  89115
Phone 702-643-6363
Fax 702-543-7010
www.gigacrete.com

B U I L D  S T R O N G.  B U I L D  F O R W A R D.

This message and any attachments are solely for the intended recipient and may contain confidential or privileged information.  If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is strictly prohibited.  If you have received this communication in error, please notify us by reply email and immediately and permanently delete this message and any attachments.



-----Original Message-----
From: pgsql-admin-owner@postgresql.org on behalf of Marc Fromm
Sent: Mon 2/8/2010 4:38 PM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] copy table

I created a new database and I want to copy a table from a different database into the new database.
1. I used phpPgAdmin and exported the table that I want a copy of.
2. In the new database I pasted the export into the SQL box in phpPgAdmin and clicked execute to create the table.
The table was created with no errors
The only problem is it did not create the sequence for the primary key.

Do I have to manually create the sequence or did I miss a step in exporting and creating the table?


Thanks

Marc