Martha Stewart called it a Good Thing when [EMAIL PROTECTED] 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 ?

[EMAIL PROTECTED]:~$ 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

/* [EMAIL PROTECTED]/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
/* [EMAIL PROTECTED]/wolfe osdb=*/ insert into student (name)
values('me'); 
INSERT 19423269 1
/* [EMAIL PROTECTED]/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

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

Reply via email to