X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1624752B16 for ; Sat, 28 May 2005 23:05:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03424-03 for ; Sun, 29 May 2005 02:05:32 +0000 (GMT) Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id 4B89C52996 for ; Sat, 28 May 2005 23:04:49 -0300 (ADT) Received: from a2s1.a2webhosting.com (host-180.a2webhosting.com [69.39.89.180]) by svr2.postgresql.org (Postfix) with ESMTP id 4EDCFF0DA0 for ; Sat, 28 May 2005 21:35:41 +0100 (BST) Received: from user-1120nve.dsl.mindspring.com ([66.32.95.238] helo=[192.168.1.10]) by a2s1.a2webhosting.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.50) id 1Dc82M-0001Zj-Ic; Sat, 28 May 2005 16:36:02 -0400 In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v619.2) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <183b3bdba4539903b1a778f815f6aa43@pgedit.com> Content-Transfer-Encoding: 7bit Cc: pgsql-admin@postgresql.org From: John DeSoi Subject: Re: Adding Serial Type Date: Sat, 28 May 2005 16:35:57 -0400 To: David Pratt X-Mailer: Apple Mail (2.619.2) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - a2s1.a2webhosting.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - pgedit.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/290 X-Sequence-Number: 17719 On May 28, 2005, at 1:27 PM, David Pratt wrote: > CREATE TABLE new_table ( > id SERIAL UNIQUE NOT NULL, > description TEXT NOT NULL > ); > > Or should I just use below because Serial type implies this. > > CREATE TABLE new_table ( > id SERIAL, > description TEXT NOT NULL > ); The first one because it is possible for the serial to wrap around or some other bad thing could happen if the serial is accidently reset. But if id is really the primary key, then I would use SERIAL PRIMARY KEY which implies UNIQUE NOT NULL. From the CREATE TABLE documentation: The primary key constraint specifies that a column or columns of a table may contain only unique (non-duplicate), nonnull values. Technically, PRIMARY KEY is merely a combination of UNIQUE and NOT NULL, but identifying a set of columns as primary key also provides metadata about the design of the schema, as a primary key implies that other tables may rely on this set of columns as a unique identifier for rows. John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL