mysql 创建表

1.删除表 drop table  table_name;                  //table_name 表名

2.创建表,当标记某个属性为主键的时候,已经创建主键索引

create 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的最大长度 六万五千

原文地址:https://www.cnblogs.com/blogxiao/p/7527327.html