我需要有关精确查询的帮助,以成功地将数据插入下面创建的表中,而不违反约束并满足表所需的条件。我尝试使用下面的查询,但失败了
INSERT INTO public.study_subject(
study_subject_id, label, secondary_label, subject_id, study_id,
status_id, enrollment_date, date_created, date_updated, owner_id,
update_id, oc_oid, time_zone, user_id, user_status_id)
VALUES (?, ?, ?, ?, ?,
?, ?, ?, ?, ?,
?, ?, ?, ?, ?);
下面是创建所述表的查询
CREATE TABLE public.study_subject
(
study_subject_id integer NOT NULL DEFAULT nextval('study_subject_study_subject_id_seq'::regclass),
label character varying(30),
secondary_label character varying(30),
subject_id integer,
study_id integer,
status_id integer,
enrollment_date date,
date_created timestamp with time zone,
date_updated timestamp with time zone,
owner_id integer,
update_id integer,
oc_oid character varying(40) NOT NULL,
time_zone character varying(255) DEFAULT ''::character varying,
user_id integer,
user_status_id integer,
CONSTRAINT pk_study_subject PRIMARY KEY (study_subject_id),
CONSTRAINT fk_project__reference_study2 FOREIGN KEY (study_id)
REFERENCES public.study (study_id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE NO ACTION,
CONSTRAINT fk_study_reference_subject FOREIGN KEY (subject_id)
REFERENCES public.subject (subject_id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE SET NULL,
CONSTRAINT fk_study_su_fk_study__status FOREIGN KEY (status_id)
REFERENCES public.status (status_id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT fk_study_su_fk_study__user_acc FOREIGN KEY (owner_id)
REFERENCES public.user_account (user_id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT study_subject_user_id_fk FOREIGN KEY (user_id)
REFERENCES public.user_account (user_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT uniq_study_subject_oid UNIQUE (oc_oid)
)
WITH (
OIDS=FALSE
);
请帮忙,任何能在这件事上提供帮助的链接/资源都将不胜感激,谢谢:)
暂无答案!
目前还没有任何答案,快来回答吧!