Answer the question
In order to leave comments, you need to log in
Why FOREIGN KEY without CONSTRAINT?
Hello!
In general, I create 2 tables and a foreign key from the 2nd to the 1st:
CREATE TABLE tbl_1 (
id SERIAL PRIMARY KEY
);
CREATE TABLE tbl_2 (
id SERIAL PRIMARY KEY,
tbl_id INT
);
ALTER TABLE tbl_2 ADD CONSTRAINT tbl_2_tbl_1__fk FOREIGN KEY (tbl_id) REFERENCES tbl_1;
INSERT INTO tbl_2 (tbl_id) VALUES (1);
ALTER TABLE tbl_1 DROP CONSTRAINT tbl_1_pkey CASCADE;
INSERT INTO tbl_2 (tbl_id) VALUES (1);
Answer the question
In order to leave comments, you need to log in
FOREIGN KEY is CONSTRAINT tbl_1_pkey
i.e. this team
you deleted FOREIGN KEY
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question