Re: Removing duplicate rows

From: Hélder M(dot) Vieira <hmv(at)mail(dot)telepac(dot)pt>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Removing duplicate rows
Date: 2007-02-06 22:49:50
Message-ID: 000c01c74a41$1ce8ffb0$6200a8c0@hmv02
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> As the table definitions get updated frequently, I'd like to put in my
> script to create the table as a copy of the existing 'real' table. I'm
> assuming "create table as" would be what I need to use, but what would I
> use as the select sql - i.e. how do I use select to pull the definition of
> a table.

The create statement allows you to copy a table structure, including or
excluding constraints.
For inclusion and exclusion effects, please read the manual info related
with the 'like' clause of the 'create table' statement.

Ex.:
create temporary table mytesttable (like mymaintable excluding constraints
excluding defaults);

Regards,

Hélder M. Vieira

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Kellerer 2007-02-06 23:15:18 Re: Removing duplicate rows
Previous Message Paul Lambert 2007-02-06 22:44:09 Re: Removing duplicate rows