From: Bath, David <dave.bath@unix.net>
To: pgsql-sql@postgresql.org
Subject: Re: create table and data types
Date: Wed, 15 Feb 2006 11:21:55 +1100
Message-ID: <200602151121.56766.dave.bath@unix.net> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dave.bath@unix.net
Subject: Re: create table and data types
In-Reply-To: <200602151121.56766.dave.bath@unix.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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