From: Christopher Browne <cbbrowne@acm.org>
To: pgsql-admin@postgresql.org
Subject: Re: SERIAL type not autoincremented
Date: Fri, 02 Jul 2004 16:19:01 -0400
Message-ID: <m3vfh65fii.fsf@wolfe.cbbrowne.com> (raw)
References: <20040702172227Z4873738-14310+28550@kps5.test.onet.pl>
Martha Stewart called it a Good Thing when 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"
>
> Why ? Do i understeand correctly that SERIAL == AUTO_INCREMENT ?
> As far as i remember i used such type in the past and had no problem.
> What do i miss ?
cbbrowne@wolfe:~$ psql osdb
Welcome to psql 7.4.3, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
/* cbbrowne@[local]/wolfe osdb=*/ create table student(
/*osdb(#*/id SERIAL NOT NULL,
/*osdb(#*/name VARCHAR(35) NOT NULL,
/*osdb(#*/primary key (id)
/*osdb(#*/);
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
/* cbbrowne@[local]/wolfe osdb=*/ insert into student (name)
values('me');
INSERT 19423269 1
/* cbbrowne@[local]/wolfe osdb=*/ \q
It sounds as though there's something more going on that you haven't
told us about.
What data was already in that table? If there wasn't anything already
there, there could hardly be a duplicate.
--
let name="cbbrowne" and tld="cbbrowne.com" in String.concat "@" [name;tld];;
http://www3.sympatico.ca/cbbrowne/lsf.html
Academics denigrating "Popularizers"
"During the rise of the merchant class, the landed aristocracy
understood the value of creating food, but didn't appreciate that food
isn't valuable unless it reaches hungry mouths.
New ideas aren't valuable unless they reach hungry minds. "
-- Mark Miller
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: cbbrowne@acm.org
Subject: Re: SERIAL type not autoincremented
In-Reply-To: <m3vfh65fii.fsf@wolfe.cbbrowne.com>
References: <20040702172227Z4873738-14310+28550@kps5.test.onet.pl> <m3vfh65fii.fsf@wolfe.cbbrowne.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