Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 33C939FA294 for ; Fri, 29 Dec 2006 22:09:55 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 74671-02 for ; Fri, 29 Dec 2006 22:09:50 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from momjian.us (momjian.us [70.90.9.53]) by postgresql.org (Postfix) with ESMTP id 89E119FA217 for ; Fri, 29 Dec 2006 22:09:50 -0400 (AST) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id kBU29nU05745; Fri, 29 Dec 2006 21:09:49 -0500 (EST) From: Bruce Momjian Message-Id: <200612300209.kBU29nU05745@momjian.us> Subject: Re: domains and serial In-Reply-To: <4591E420.3040102@williamrosmus.com> To: BillR Date: Fri, 29 Dec 2006 21:09:49 -0500 (EST) CC: pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL123] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/193 X-Sequence-Number: 27149 BillR wrote: > Is it not possible to set up a domain using this construct? I will have > a lot of tables using integer and big integer types as primary key > identifier fields. It would make things simpler if I can use the serial > construct in a domain instead of using an int or bigint in the domain, > and then change each field in each table requiring a serial or bigserial > construct. > > I just tried to create a domain using a bigserial type. > > CREATE DOMAIN Identifier_DM AS bigserial; > > I received the error message: > > ERROR: type "bigserial" does not exist > SQL state: 42704 > > I tried to run this in both pgadminIII and in data architect 3.5. Yea, that isn't going to work because if you did that, all columns created with that domain name would have the same default sequence. See: test=> CREATE TABLE test(x bigserial); NOTICE: CREATE TABLE will create implicit sequence "test_x_seq" for serial column "test.x" CREATE TABLE test=> \d test Table "public.test" Column | Type | Modifiers --------+--------+-------------------------------------------------- x | bigint | not null default nextval('test_x_seq'::regclass) I don't see how we would ever get that working for domains. The best we could do would be to have each new domain reference create a new sequence and default string, but then you just have the bigserial behavior in a domain, which doesn't seem worth it. -- Bruce Momjian bruce@momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. +