Post by Andreas KretschmerPost by Dominik EchterbruchPost by Weinzierl Stefan128x INSERT INTO test(id) VALUES(NULL);
ERROR 1062 (23000): Duplicate entry '127' for key 1
Das ist interessant. Früher lautete die Fehlermeldung mal "Table full".
Yeah. Die Fehlermeldungen von MySQL werden sinnvoller. Aber so richtig
sinnvoll sind sie noch nicht...
Um zu erklären, was ich meine:
,----[ Sequence ohne CYCLE ]
| test=# create table voll (id bigserial, val text);
| NOTICE: CREATE TABLE will create implicit sequence "voll_id_seq" for serial column "voll.id"
| CREATE TABLE
| test=# insert into voll (id) values (nextval('voll_id_seq'));
| INSERT 0 1
| test=# select setval('voll_id_seq', 9223372036854775806);
| setval
| ---------------------
| 9223372036854775806
| (1 row)
|
| test=# insert into voll (id) values (nextval('voll_id_seq'));
| INSERT 0 1
| test=# insert into voll (id) values (nextval('voll_id_seq'));
| ERROR: nextval: reached maximum value of sequence "voll_id_seq" (9223372036854775807)
`----
,----[ Sequence mit CYCLE gesetzt ]
| test=# create table voll (id bigserial primary key, val text);
| NOTICE: CREATE TABLE will create implicit sequence "voll_id_seq" for serial column "voll.id"
| NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "voll_pkey" for table "voll"
| CREATE TABLE
| test=# insert into voll (id) values (nextval('voll_id_seq'));
| INSERT 0 1
| test=# select setval('voll_id_seq', 9223372036854775806);
| setval
| ---------------------
| 9223372036854775806
| (1 row)
|
| test=# alter SEQUENCE voll_id_seq CYCLE;
| ALTER SEQUENCE
| test=# insert into voll (id) values (nextval('voll_id_seq'));
| INSERT 0 1
| test=# insert into voll (id) values (nextval('voll_id_seq'));
| ERROR: duplicate key violates unique constraint "voll_pkey"
| test=#
`----
Offensichtlich macht MySQL von sich aus ein CYCLE, und merkt erst dann,
daß da schon was ist. Womit die Frage des Fragestellers wohl beantwortet
wäre.
Post by Andreas Kretschmerend
Andreas
--
q: why do so many people take an instant dislike to mysql?
a: it saves time (oicu in #postgresql)
Explaining the concept of referential integrity to a mysql user is like
explaining condoms to a catholic (Shadda in #postgresql)
end
Andreas
--
q: why do so many people take an instant dislike to mysql?
a: it saves time (oicu in #postgresql)
Explaining the concept of referential integrity to a mysql user is like
explaining condoms to a catholic (Shadda in #postgresql)