Re: create table and data types - Mailing list pgsql-sql

From Bath, David
Subject Re: create table and data types
Date
Msg-id 200602151121.56766.dave.bath@unix.net
Whole thread Raw
In response to create table and data types  (Maciej Piekielniak <piechcio@isb.com.pl>)
List 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.bath@unix.net



pgsql-sql by date:

Previous
From: Ken Hill
Date:
Subject: Re: create table and data types
Next
From: Ken Hill
Date:
Subject: Re: Non Matching Records in Two Tables