美文网首页
mysql constraints

mysql constraints

作者: BenjaminCool | 来源:发表于2019-01-07 09:56 被阅读27次

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.

相关文章

网友评论

      本文标题:mysql constraints

      本文链接:https://www.haomeiwen.com/subject/wymyrqtx.html