Re: create table and data types

From: "Bath, David" <dave(dot)bath(at)unix(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: create table and data types
Date: 2006-02-15 00:21:55
Message-ID: 200602151121.56766.dave.bath@unix.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, 2006-02-14 at 22:12 +0100, Maciej Piekielniak wrote: (snipped)
>Is anybody know how create field in a new table with data type accuiring
>from a field in other table?
>For example:
> create table new_table ( name other_table.name%TYPE);

On Wed, 15 Feb 2006 09:42, Ken Hill wrote: (snipped)
> Have you tried restructuring the table with CREATE TABLE AS...?
> Try this:
> CREATE TABLE new_table
>      (id, mynewfield, mynewfield2)
>      AS SELECT id FROM old_table);

I use a similar technique, but add a "WHERE 1=0" so the new table is
empty.  Of course, more than a single table can be referenced in the
FROM clause.
--
David T. Bath
dave(dot)bath(at)unix(dot)net

Browse pgsql-sql by date

  From Date Subject
Next Message Ken Hill 2006-02-15 01:47:02 Re: Non Matching Records in Two Tables
Previous Message Bryce Nesbitt 2006-02-14 23:05:10 Re: Non Matching Records in Two Tables