当前位置:Gxlcms > 数据库问题 > mysql 创建表

mysql 创建表

时间:2021-07-01 10:21:17 帮助过:27人阅读

table student_info(
  id int not null auto_increment primary key comment ‘主键id‘,
  name varchar(20) null comment ‘姓名‘,
  
unique id(id asc) //创建主键唯一索引
  

);

mysql 索引的分类   显示表的索引  

 show index from table;

 

normal  

   创建方式

indexcolumn   desc|asc)   #index 索引别名   column 字段名

   特点:普通索引

unique |full text  

  创建方式

 unique index(column desc|asc)

  特点:unique   要求唯一   full text  耗时耗空间

 

3.时间戳格式

create table student(

  id int not null primary key,
    
    createTime timetamp  #时间戳格式 默认为0000-00-00  00:00:00格式的时间
);

4. 整型

  tinyint  一个字节

  smallint  2个字节

  int  4个字节

  bigint 8个字节   

 

5. char 和varchar  mysql5之后存的是字符   varchar的最大长度 六万五千

 

mysql 创建表

标签:创建表   mys   com   char   orm   tin   rom   mysql   har   

人气教程排行