在postgresql中:
第1步:
我收到了错误:
ERROR: duplicate key value violates unique constraint "question_pkey"
DETAIL: Key (id)=(11) already exists.
STATEMENT: INSERT INTO question (content,uid,answer_count,answer_users,view_count,status,created_at,updated_at,attach) values ($1,$2,$3,$4,$5,$6,$7,$8,$9) returning *
LOG: statement: DEALLOCATE pdo_stmt_00000001
第二步:
我称之为句子:
master=# ALTER SEQUENCE question_id_seq RESTART WITH 110702;
步骤3:
插入一个问题,但是question_id是11而不是我期望的110703。
我的表格如下:
CREATE TABLE question (
id serial NOT NULL PRIMARY KEY,
content text,
uid int NOT NULL DEFAULT 0,
attach text NOT NULL DEFAULT '',
answer_count int NOT NULL DEFAULT 0,
status smallint NOT NULL DEFAULT 0
);
添加我的服务器日志:
LOG: statement:
LOG: statement: insert into "public"."question" ( "uid", "content") values ( '1', '1')
ERROR: duplicate key value violates unique constraint "question_pkey"
DETAIL: Key (id)=(30) already exists.
STATEMENT: insert into "public"."question" ( "uid", "content") values ( '1', '1')
LOG: statement:
LOG: statement: ALTER SEQUENCE question_id_seq RESTART WITH 110706
LOG: statement:
LOG: statement: insert into "public"."question" ( "uid", "content") values ( '1', '1')
ERROR: duplicate key value violates unique constraint "question_pkey"
DETAIL: Key (id)=(31) already exists.
STATEMENT: insert into "public"."question" ( "uid", "content") values ( '1', '1')
答案 0 :(得分:0)
我错了,\ d问题显示我不使用quesiton_id_seq,但使用question_id_seq1。谢谢mu