How to clone a table to an empty one
How to clone a table to an empty one
От:
Ramiro Alba <ramiro@labtie.mmt.upc.es>
Дата:
Hello everyone: I would need to create an exact reproduction of a certain table (excluding data) converving primary key attributes and so on. I tried with: CREATE TABLE AS ... I also tried : SELECT * INTO TABLE .... In both cases, it does not maintain the primary key atribute that I need in order to edit the cloned table with StarBase using the unixODBC driver. The table reads ok, but it is read only due to the fact that I mention. Anyone knows the solution? Regards -- Ramiro Alba Laboratori de Termotecnia i Energetica Departament de Maquines i Motors Termics ETS d'Enginyers Industrials de Terrassa C/Colom 11 Tf: 34 - 93 739 86 46 Fax: 34 - 93 739 81 01 e-mail: ramiro@labtie.mmt.upc.es
Re: How to clone a table to an empty one
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Ramiro Alba writes: > I would need to create an exact reproduction of a certain table > (excluding data) converving primary key attributes and so on. Trypg_dump -s -t tablename dbname | psql dbname There is no easy way to do this directly in SQL ... regards, tom lane