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

Re: 7.4: serial not working ?

From: Gaetano Mendola <mendola(at)bigfoot(dot)com>
To: vertigo <none(at)microsoft(dot)com>
Subject: Re: 7.4: serial not working ?
Date: 2004-07-03 14:54:56
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
vertigo wrote:

> Hello
> i upgraded postgresql from 7.3 to 7.4 and noticed that SERIAL
> exists but does not working. Example:
> My table:
> create table1(
> id SERIAL,
> name VARCHAR(100)
> );
> insert into table1 (name) values('name1');
> ERROR:  duplicate key violates unique constraint "table1_pkey"
> Why ? I want to have autoincrementation. I do not know (when i insert 
> record) what id values should it have.
> How can i solve this problem ?

when you define the serial it start from 1. If you filled that table
specifing also the serial value then the serial was not incremented,
in order to solve your problem setting the serial value equal to
max(id)+1 in that table.

Gaetano Mendola

In response to

pgsql-bugs by date

Next:From: Dario V. FassiDate: 2004-07-03 17:06:55
Subject: Re: Error in DatabaseMetaData.getColumns() with Views
Previous:From: Gaetano MendolaDate: 2004-07-03 14:51:50
Subject: Re: BUG #1186: Broken Index?

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