标签:font comm unique ext 字段 name 作用 table 自动
mysql中常见的数据类型:
varchar(n) ,float ,int(n) ,bigint(n) ,date ,datetime ,text;
默认值:default ‘默认值‘
非空:not null , 如果某一字段被not null修饰后,添加数据时 , 此字段必须填写
自动增长:auot_increment , 尽量作用在int类型字段上;想把之前连着的数据也删了得使用truncate来删
主键:primary key , 不能够重复 ,一张表中只有一个字段可以作为主键
唯一键: unique , 被unique修饰的数据不能够重复
示例
create table student(
id int(20) auto_increment primary key comment ‘学生编号‘,
varchar(2) default ‘男‘ comment ‘性别‘,
classname varchar(20) NOT NULL comment ‘ 班级 ‘;
)
truncate删除:
如果要删除一整张表的数据,使用truncate.使用truncate删除数据后,
如果字段是自增的,则重新从1开始;
如果使用delete删除一整张表的数据,则自增列不会从1开始
标签:font comm unique ext 字段 name 作用 table 自动
原文地址:https://www.cnblogs.com/xiaocaonb/p/12905879.html