错误:关系“ student_id_seq”不存在SQL状态:42P01

时间:2019-03-12 06:48:37

标签: postgresql

我有以下SQL代码:

-- Table: public.student

-- DROP TABLE public.student;

CREATE TABLE public.student
(

   id integer NOT NULL DEFAULT nextval('student_id_seq'::regclass),
   country character varying(30) COLLATE pg_catalog."default" NOT NULL,
   email character varying(30) COLLATE pg_catalog."default" NOT NULL,
   first_name character varying(255) COLLATE pg_catalog."default" NOT NULL,
   last_name character varying(255) COLLATE pg_catalog."default" NOT NULL,
   section character varying(255) COLLATE pg_catalog."default" NOT NULL,
   sex character varying(255) COLLATE pg_catalog."default" NOT NULL,
   CONSTRAINT student_pkey PRIMARY KEY (id)
)
WITH (
  OIDS = FALSE
) 
TABLESPACE pg_default;

ALTER TABLE public.student
OWNER to postgres;

我的查询无法执行

  

错误:关系“ student_id_seq”不存在   SQL状态:42P01

1 个答案:

答案 0 :(得分:0)

您可以创建序列或创建具有序列类型的id列。