如果要对UPDATE 和 DELETE 加上 CASCADE,可以这么写
CREATE TABLE users1 (id SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, username VARCHAR(10) NOT NULL, pid SMALLINT UNSIGNED, FOREIGN KEY (pid) REFERENCES provinces (id) ON DELETE CASCADE ON UPDATE CASCADE);
如果要对UPDATE 和 DELETE 加上 CASCADE,可以这么写
CREATE TABLE users1 (id SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, username VARCHAR(10) NOT NULL, pid SMALLINT UNSIGNED, FOREIGN KEY (pid) REFERENCES provinces (id) ON DELETE CASCADE ON UPDATE CASCADE);
2014-10-26
举报