pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to clone a table to an empty one
2+ messages / 2 participants
[nested] [flat]

* How to clone a table to an empty one
@ 2001-02-17 14:55  Ramiro Alba <ramiro@labtie.mmt.upc.es>
  0 siblings, 1 reply; 2+ messages in thread

From: Ramiro Alba @ 2001-02-17 14:55 UTC (permalink / raw)
  To: pgsql-sql

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






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: How to clone a table to an empty one
@ 2001-02-17 16:25  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Ramiro Alba <ramiro@labtie.mmt.upc.es>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2001-02-17 16:25 UTC (permalink / raw)
  To: Ramiro Alba <ramiro@labtie.mmt.upc.es>; +Cc: pgsql-sql

Ramiro Alba <ramiro@labtie.mmt.upc.es> writes:
> I would need to create an exact reproduction of a certain table
> (excluding data) converving primary key attributes and so on.

Try
	pg_dump -s -t tablename dbname | psql dbname

There is no easy way to do this directly in SQL ...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-02-17 16:25 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-02-17 14:55 How to clone a table to an empty one Ramiro Alba <ramiro@labtie.mmt.upc.es>
2001-02-17 16:25 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox