enum 单选行为
set 对选行为
create table t8(
id int,
name char(18),
gender enum(‘nale‘,‘female‘));
create table t10(
id int,
name char(18),
hobby set(‘film‘,‘aiai‘,‘dance‘),
time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
约束:某一个字段不要为空。
无符号的 只和数字有关 int unsigned
不能为空 not null
设置严格模式:
不支持对not null字段插入null值
不支持对自增长字段插入”值
不支持text字段有默认值
直接在mysql中生效(重启失效):
mysql>set sql_mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";
配置文件添加(永久失效):
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
not null不生效
默认值
不能重复
自增
主键
外键
原文:https://www.cnblogs.com/ch2020/p/12879180.html