Difference between revisions of "Mysql setting constraints"
From MyWiki
Line 1: | Line 1: | ||
+ | https://www.percona.com/blog/2017/04/06/dealing-mysql-error-code-1215-cannot-add-foreign-key-constraint<br> | ||
+ | |||
<source lang="sql"> | <source lang="sql"> | ||
+ | |||
+ | |||
+ | |||
CONSTRAINT education_ibfk_1 | CONSTRAINT education_ibfk_1 | ||
FOREIGN KEY (profile_id) | FOREIGN KEY (profile_id) | ||
Line 17: | Line 22: | ||
FOREIGN KEY (hostname) | FOREIGN KEY (hostname) | ||
REFERENCES sslhosts (hostname) | REFERENCES sslhosts (hostname) | ||
− | |||
); | ); | ||
</source> | </source> | ||
http://www.mysqltutorial.org/mysql-primary-key/<br> | http://www.mysqltutorial.org/mysql-primary-key/<br> |
Revision as of 12:33, 22 January 2019
CONSTRAINT education_ibfk_1 FOREIGN KEY (profile_id) REFERENCES Profile (profile_id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT education_ibfk_2 FOREIGN KEY (institution_id) REFERENCES Institution (institution_id) ON DELETE CASCADE ON UPDATE CASCADE, CREATE TABLE notes ( hostname VARCHAR(30), notes VARCHAR(100), CONSTRAINT myconst_1 FOREIGN KEY (hostname) REFERENCES sslhosts (hostname) );