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

Re: SERIAL and Primary Key

From: Erik Jones <erik(at)myemma(dot)com>
To: mgould(at)allcoast(dot)net
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SERIAL and Primary Key
Date: 2008-02-29 20:55:28
Message-ID: DDDBF231-EF31-4513-B3AF-C7567BB2C581@myemma.com (view raw or flat)
Thread:
Lists: pgsql-general
On Feb 29, 2008, at 2:28 PM, Mike Gould wrote:

> CREATE TABLE "fav5"."batchnumber" (
>   "batchnumberid" SERIAL NOT NULL,
>   "processtype" SMALLINT NOT NULL,
>   "termloc" CHAR(3) NOT NULL,
>   "batchno" INTEGER NOT NULL
> ) WITHOUT OIDS;
> 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?
>

No, you need to add the PRIMARY KEY bit which means you can also drop  
the NOT NULL bit for that field.

Erik Jones

DBA | Emma®
erik(at)myemma(dot)com
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com




In response to

pgsql-general by date

Next:From: hubert depesz lubaczewskiDate: 2008-02-29 20:56:43
Subject: Re: SERIAL and Primary Key
Previous:From: Alvaro HerreraDate: 2008-02-29 20:53:39
Subject: Re: Removing Users and Revoking Privileges

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