Re: pg_dump serial UNIQUE NOT NULL PRIMARY KEY

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Michael Hipp <Michael(at)Hipp(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pg_dump serial UNIQUE NOT NULL PRIMARY KEY
Date: 2005-04-22 22:04:54
Message-ID: 20050422220454.GA94766@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Apr 22, 2005 at 04:44:05PM -0500, Michael Hipp wrote:
>
> Hello, I'm a fairly new user of PostgreSQL 8.0.2 and I'm creating a table
> like this:
>
> CREATE TABLE cases (
> id serial PRIMARY KEY,
>
> Works fine, but when I pg_dump the database, what shows up in the dump is:
>
> CREATE TABLE cases (
> id serial NOT NULL,
>
> The documentation seems to say that 'serial NOT NULL' is not at all the
> same as 'serial PRIMARY KEY':

Later in the dump file you should see something like this:

ALTER TABLE ONLY cases
ADD CONSTRAINT cases_pkey PRIMARY KEY (id);

Presumably that's because adding the primary key constraint after
populating the table is more efficient than populating the table
with the constraint (and the associated index) in place.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2005-04-22 22:08:33 Re: libpq Unicode support?
Previous Message David Roussel 2005-04-22 22:03:23 Re: PHP and Postgresql on Windows