Re: SERIAL type not autoincremented

From: teknet(at)poczta(dot)onet(dot)pl
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: SERIAL type not autoincremented
Date: 2004-07-02 19:40:02
Message-ID: 20040702194010Z137290-15166+26852@kps2.test.onet.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

i found the problem:

 

sys=> create table test2(
sys(> id serial,
sys(> name varchar(10),
sys(> primary key(id)
sys(> );
NOTICE:  CREATE TABLE will create implicit sequence "test2_id_seq" for
"serial" column "test2.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "test2_pkey"
for table "test2"
CREATE TABLE
sys=> insert into test2 values(1,'myname');
INSERT 18765 1
sys=> insert into test2 (name) values('myname2');
ERROR:  duplicate key violates unique constraint "test2_pkey"
sys=>

Why is it so ?

 

Thanx

Michal

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Radu-Adrian Popescu 2004-07-02 20:11:52 Re: SERIAL type not autoincremented
Previous Message Christopher Browne 2004-07-02 19:15:13 Re: Dumping partial database content