Nick Urbanik wrote:
> It seems that PostgreSQL 7.3.8 does not support create table
> table_name like original_table.
>
> Can you suggest a way I can create a duplicate table with the same
> triggers and other stuff that this table has?
>
> What is the most efficient way to copy the data?
Something like:
CREATE TABLE mytable_copy AS SELECT * FROM mytable;
ALTER TABLE mytable RENAME TO mytable_old;
ALTER TABLE mytable_copy RENAME TO mytable;
/*
Now add primary key, indices, foreign keys, triggers, rules, column
defaults to mytable, and you'll probably want to drop the foreign keys at
least from mytable_old. I'm afraid you'll have to sort out manually what
these should be.
*/
7.3.8 is quite seriously old. 7.3.19 is the latest in that tree if you must
stick with it.
HTH,
Geoff