Skip site navigation (1) Skip section navigation (2)

Re: SERIAL and Primary Key

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: mgould(at)allcoast(dot)net
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SERIAL and Primary Key
Date: 2008-03-01 01:29:03
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Fri, Feb 29, 2008 at 2:28 PM, Mike Gould <mgould(at)allcoast(dot)net> wrote:
> CREATE TABLE "fav5"."batchnumber" (
>   "batchnumberid" SERIAL NOT NULL,
>   "processtype" SMALLINT NOT NULL,
>   "termloc" CHAR(3) NOT NULL,
>   "batchno" INTEGER NOT NULL
> With the above table definition, is batchnumberid by default also defined as
> the primary key or do I still need to define a separate Primary Key
> constraint?

Once upon a time a serial type was assumed to be a PK (or was that
unique not null???) automagically.  However, this was considered bad
form since some uses of sequence did not need those extra settings.

Serial is JUST serial nowadays, and has been for quite some time.

In response to

pgsql-general by date

Next:From: Tom LaneDate: 2008-03-01 02:04:17
Subject: Re: Confused about CASE
Previous:From: brianDate: 2008-03-01 00:44:37
Subject: Re: pgsql structure export to XML

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group