mysql constraints
2019-01-07 本文已影响27人
BenjaminCool
1⃣️ not null
2⃣️ unique
3⃣️ primary key
4⃣️ foreign key
5⃣️ default
6⃣️ check
https://www.w3resource.com/mysql/creating-table-advance/constraint.php
check: mysql不支持 check constraint,如果写了, 会被 mysql 忽略的。
CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
CHECK (Age>=18)
);
http://www.mysqltutorial.org/mysql-check-constraint/
Unfortunately, MySQL does not support CHECK constraint. Actually, MySQL accepts the CHECK clause in the CREATE TABLE statement but it ignores it silently.