报relation “performance_id_seq” does not exist
运行如下建表语句,报错:
-- 建表,并用上面的序列作为主键自增序列 CREATE TABLE public.user_camera_version ( ? ? id int4 NOT NULL DEFAULT nextval('performance_id_seq'::regclass), ? ? user_id int4 NULL, ? ? user_type varchar(1) NULL, ? ? hardware_version varchar(100) NULL, ? ? software_version varchar(100) NULL, ? ? modify_date timestamp NULL, ? ? CONSTRAINT user_camera_version_pkey PRIMARY KEY (id) ) ?;
在postgresql表中建立了自增字段,id定义为Serial 类型,当执行完成建表语句后,其字段便成: “id” int4 NOT NULL DEFAULT nextval(‘performance_id_seq’::regclass) 这种形式 但是导出sql脚本时候直接定义成这种形式,postgresql不能识别,想必是postgresql的一个小bug吧,因此自增的id,在建表的时候应该定义为: “id” serial
要先创建performance_id_seq序列
CREATE SEQUENCE "performance_id_seq" START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
删除某个序列:
DROP SEQUENCE performance_id_seq
|