X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id BA3FB9DC80F for ; Tue, 14 Feb 2006 20:17:15 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03520-05 for ; Tue, 14 Feb 2006 20:17:18 -0400 (AST) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 91B489DC81F for ; Tue, 14 Feb 2006 20:17:13 -0400 (AST) Received: from mailrouter.internal.box (unknown [203.48.241.83]) by svr4.postgresql.org (Postfix) with ESMTP id CE5D95AF0BA for ; Wed, 15 Feb 2006 00:17:16 +0000 (GMT) Received: from localhost (localhost [IPv6:::1]) by mailrouter.internal.box (Postfix) with ESMTP id 06BE32210C1 for ; Wed, 15 Feb 2006 11:21:58 +1100 (EST) From: "Bath, David" Reply-To: 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 User-Agent: KMail/1.8 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200602151121.56766.dave.bath@unix.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200602/161 X-Sequence-Number: 24171 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?=20 >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 > =A0 =A0 =A0(id, mynewfield, mynewfield2) > =A0 =A0 =A0AS SELECT id FROM old_table); I use a similar technique, but add a "WHERE 1=3D0" so the new table is empty. =A0Of course, more than a single table can be referenced in the =46ROM clause. =2D-=20 David T. Bath dave.bath@unix.net