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

mysql 创建表

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

table student_info(
  id int not null auto_increment primary key comment ‘主键id‘,
  1. <span style="color: #0000ff">  name varchar(20) null comment ‘姓名‘,<br>  <br> unique id(id asc) //创建主键唯一索引<br>  <br><br>);</span>

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

  1. show <span style="color: #0000ff">index</span> <span style="color: #0000ff">from</span> <span style="color: #0000ff">table</span>;

 

normal  

   创建方式

  1. <span style="color: #0000ff">index</span>(<span style="color: #0000ff">column</span> <span style="color: #0000ff">desc</span><span style="color: #808080">|</span><span style="color: #0000ff">asc</span>)  #index 索引别名   column 字段名

   特点:普通索引

unique |full text  

  创建方式

  1. <span style="color: #0000ff">unique</span> <span style="color: #0000ff">index</span>(<span style="color: #0000ff">column</span> <span style="color: #0000ff">desc</span><span style="color: #808080">|</span><span style="color: #0000ff">asc</span>)

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

 

3.时间戳格式

  1. <span style="color: #0000ff">create</span> <span style="color: #0000ff">table</span><span style="color: #000000"> student(
  2.   id </span><span style="color: #0000ff">int</span> <span style="color: #808080">not</span> <span style="color: #0000ff">null</span> <span style="color: #0000ff">primary</span> <span style="color: #0000ff">key</span><span style="color: #000000">,
  3. createTime timetamp #时间戳格式 默认为0000-00-00 00:00:00格式的时间
  4. );</span>

4. 整型

  tinyint  一个字节

  smallint  2个字节

  int  4个字节

  bigint 8个字节   

 

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

 

mysql 创建表

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

人气教程排行