Re: primary key error with PostgreSQL

[prev] [thread] [next] [Date index for 2005/05/20]

From: Brett Sanger
Subject: Re: primary key error with PostgreSQL
Date: 13:26 on 20 May 2005
On Fri, May 20, 2005 at 07:25:35AM +0100, Tony Bowden wrote:
> On Fri, May 20, 2005 at 07:03:23AM +0100, cesmky@xxxxx.xxx wrote:
> >   itemid INTEGER PRIMARY KEY,
> 
> On SQLite this acts as an "auto incrementing" column. So when you don't
> give a value for it, SQLite will fill one in for you. This isn't true of
> Pg. You either need to give it a value, or add a sequence on that
> column if you want an automagic value.

The "easiest" way to use a sequence in this case would be to have:

itemid SERIAL PRIMARY KEY

which would be similar to the behavior SQLite gives you.  If you look up
"serial" and "sequence" in the postgres docs you should fine much more
info.

        -- 
        SwiftOne  /  Brett Sanger
swiftone@xxxxxxxx.xxx   

primary key error with PostgreSQL
cesmky 06:03 on 20 May 2005

Re: primary key error with PostgreSQL
Tony Bowden 06:25 on 20 May 2005

Re: primary key error with PostgreSQL
Brett Sanger 13:26 on 20 May 2005

Re: primary key error with PostgreSQL
Sam Kelly 02:49 on 21 May 2005

Re: primary key error with PostgreSQL
Cees Hek 00:13 on 22 May 2005

Re: primary key error with PostgreSQL
Sam Kelly 01:09 on 22 May 2005

Generated at 15:51 on 25 May 2005 by mariachi v0.52