COMMENT 对标字段注释
语法
Create table(
字段名 类型 是否为空 主外键 COMMENT ‘注释信息’,
);
Constraint 取名
设置外键
constraint FK_C foreign key (字段名) references 关联表(关联字段)
级联更新,级联删除,设置级联时,主外键就确定了下来,不需要再设外键
FOREIGN KEY (外键表外键) REFERENCES 主表(主键) ON DELETE CASCADE ON UPDATE CASCADE
Sql判断
--简单case函数
case sex
when '1' then '男'
when '2' then '女’ else '其他' end --case搜索函数 case when sex = '1' then '男' when sex = '2' then '女' else '其他' end