File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change 1- -- impossible to enforce so set NULL
2- UPDATE Postlinks SET postid= NULL WHERE postid NOT IN (SELECT DISTINCT id FROM Posts);
3- ALTER TABLE Postlinks ADD CONSTRAINT fk_postlinks_postid FOREIGN KEY (postid) REFERENCES posts (id);
4- UPDATE Postlinks SET relatedpostid= NULL WHERE relatedpostid NOT IN (SELECT DISTINCT id FROM Posts);
5- ALTER TABLE Postlinks ADD CONSTRAINT fk_postlinks_relatedpostid FOREIGN KEY (relatedpostid) REFERENCES posts (id);
1+ -- impossible to enforce these constraints, set as 'not valid' to disable
2+ -- initial test.
3+ --
4+ -- These constaints can be forced running the following queries:
5+ -- UPDATE Postlinks SET postid=NULL WHERE postid NOT IN (SELECT DISTINCT id FROM Posts);
6+ -- ALTER TABLE Postlinks VALIDATE CONSTRAINT fk_postlinks_postid;
7+ -- UPDATE Postlinks SET relatedpostid=NULL WHERE relatedpostid NOT IN (SELECT DISTINCT id FROM Posts);
8+ -- ALTER TABLE Postlinks VALIDATE CONSTRAINT fk_postlinks_relatedpostid;
9+ --
10+ ALTER TABLE Postlinks ADD CONSTRAINT fk_postlinks_postid FOREIGN KEY (postid) REFERENCES posts (id) NOT VALID;
11+ ALTER TABLE Postlinks ADD CONSTRAINT fk_postlinks_relatedpostid FOREIGN KEY (relatedpostid) REFERENCES posts (id) NOT VALID;
Original file line number Diff line number Diff line change 11ALTER TABLE Votes ADD CONSTRAINT fk_votes_userid FOREIGN KEY (userid) REFERENCES users (id);
2- -- impossible to enforce so set NULL
3- UPDATE Votes SET postid= NULL WHERE postid NOT IN (SELECT DISTINCT id FROM Posts);
2+ -- impossible to enforce this constraint, set as 'not valid' to disable
3+ -- initial test.
4+ --
5+ -- This constaint can be forced running the following queries:
6+ -- UPDATE Votes SET postid=NULL WHERE postid NOT IN (SELECT DISTINCT id FROM Posts);
7+ -- ALTER TABLE Botes VALIDATE CONSTRAINT fk_votes_postid;
8+ --
49ALTER TABLE Votes ADD CONSTRAINT fk_votes_postid FOREIGN KEY (postid) REFERENCES posts (id);
You can’t perform that action at this time.
0 commit comments