Re: SERIAL type not autoincremented

Поиск
Список
Период
Сортировка
От Christopher Browne
Тема Re: SERIAL type not autoincremented
Дата
Msg-id m3vfh65fii.fsf@wolfe.cbbrowne.com
обсуждение исходный текст
Ответ на SERIAL type not autoincremented  (teknet@poczta.onet.pl)
Список pgsql-admin
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

В списке pgsql-admin по дате отправления:

Предыдущее
От: "Bender, Cheryl"
Дата:
Сообщение: Re: Dumping partial database content
Следующее
От: Michelle Konzack
Дата:
Сообщение: Re: 32mb scsi system