From: jseymour@linxnet.com
To: pgsql-admin@postgresql.org
Subject: Re: SERIAL type not autoincremented
Date: Fri, 2 Jul 2004 14:09:34 -0400 (EDT)
Message-ID: <20040702180934.4DEA4430E@jimsun.linxnet.com> (raw)
In-Reply-To: <20040702172227Z4873738-14310+28550@kps5.test.onet.pl>
teknet@poczta.onet.pl wrote:
>
> Hello
> i have:
> create table student(
> id SERIAL NOT NULL,
> name VARCHAR(35) NOT NULL,
> primary key (id)
> );
>
> and when i try to insert like this:
> insert into student (name) values('me');
> i receive error:
> ERROR: duplicate key violates unique constraint "student_pkey"
You must be leaving something out of the story...
$ psql
Password:
Welcome to psql 7.4.2, the PostgreSQL interactive terminal.
...
jseymour=# create table student(
jseymour(# id SERIAL NOT NULL,
jseymour(# name VARCHAR(35) NOT NULL,
jseymour(# primary key (id)
jseymour(# );
NOTICE: CREATE TABLE will create implicit sequence "student_id_seq"
for "serial" column "student.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"student_pkey" for table "student"
CREATE TABLE
jseymour=# insert into student (name) values('me');
INSERT 8776502 1
jseymour=# insert into student (name) values('me');
INSERT 8776503 1
jseymour=# insert into student (name) values('me');
INSERT 8776504 1
jseymour=# select * from student;
id | name
----+------
1 | me
2 | me
3 | me
(3 rows)
Seems to work here.
Jim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: jseymour@linxnet.com
Subject: Re: SERIAL type not autoincremented
In-Reply-To: <20040702180934.4DEA4430E@jimsun.linxnet.com>
References: <20040702172227Z4873738-14310+28550@kps5.test.onet.pl> <20040702180934.4DEA4430E@jimsun.linxnet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox