Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

mysql - Foreign key constraints: When to use ON UPDATE and ON DELETE

CREATE TABLE COMPANY (
     company_id INT NOT NULL,
     company_name VARCHAR(50),
     PRIMARY KEY (company_id)
) ENGINE=INNODB;

CREATE TABLE USER (
     user_id INT, 
     user_name VARCHAR(50), 
     company_id INT,
     INDEX company_id_idx (company_id),
     FOREIGN KEY (company_id) REFERENCES COMPANY (company_id) ON...
) ENGINE=INNODB;
Source by sqlerrors.com #
 
PREVIOUS NEXT
Tagged: #mysql #Foreign #key #When #ON #UPDATE #ON #DELETE
ADD COMMENT
Topic
Name
1+5 =