Re: How to clone a table to an empty one

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ramiro Alba <ramiro(at)labtie(dot)mmt(dot)upc(dot)es>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to clone a table to an empty one
Date: 2001-02-17 16:25:09
Message-ID: 3867.982427109@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Ramiro Alba <ramiro(at)labtie(dot)mmt(dot)upc(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Roberto Mello 2001-02-18 00:34:22 PL/SQL-to-PL/PgSQL-HOWTO beta Available
Previous Message Ramiro Alba 2001-02-17 14:55:36 How to clone a table to an empty one