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 364C09DC9AC for ; Tue, 14 Feb 2006 17:30:03 -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 69599-08 for ; Tue, 14 Feb 2006 17:30:04 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [204.127.192.82]) by postgresql.org (Postfix) with ESMTP id F1E289DC988 for ; Tue, 14 Feb 2006 17:29:59 -0400 (AST) Received: from [10.0.1.5] (c-24-20-199-254.hsd1.or.comcast.net[24.20.199.254]) by comcast.net (rwcrmhc12) with SMTP id <20060214212956m1200qn7gde>; Tue, 14 Feb 2006 21:30:01 +0000 Subject: Re: create table and data types From: Ken Hill Reply-To: ken@scottshill.com To: Maciej Piekielniak Cc: pgsql-sql@postgresql.org In-Reply-To: <1827225102.20060214221218@isb.com.pl> References: <1827225102.20060214221218@isb.com.pl> Content-Type: multipart/alternative; boundary="=-rviaqhwKaOYfsfRmy5Ol" Organization: Scotts Hill Associates, Inc. Date: Tue, 14 Feb 2006 13:30:34 -0800 Message-Id: <1139952634.3083.72.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.083 required=5 tests=[AWL=0.082, HTML_MESSAGE=0.001] X-Spam-Score: 0.083 X-Spam-Level: X-Archive-Number: 200602/157 X-Sequence-Number: 24167 --=-rviaqhwKaOYfsfRmy5Ol Content-Type: text/plain Content-Transfer-Encoding: 7bit On Tue, 2006-02-14 at 22:12 +0100, Maciej Piekielniak wrote: > Hello pgsql-sql, > > 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 > ); > Have you tried inheritance from one table to the new table? CREATE TABLE new_table (new_column) INHERITS (old_table) All columns in 'old_table' will be inclueded in 'new_table' plus the column 'new_column'. --=-rviaqhwKaOYfsfRmy5Ol Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit On Tue, 2006-02-14 at 22:12 +0100, Maciej Piekielniak wrote:
Hello pgsql-sql,

  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
); 

Have you tried inheritance from one table to the new table?

CREATE TABLE new_table (new_column)
     INHERITS (old_table)

All columns in 'old_table' will be inclueded in 'new_table' plus the column 'new_column'. --=-rviaqhwKaOYfsfRmy5Ol--