首页 > 数据库技术 > 详细

MySQL基础 三 数值类型,索引

时间:2016-04-25 01:01:45      阅读:305      评论:0      收藏:0      [点我收藏+]

My 1am,1pm

数值类型

  1. Int(4)

  2. Float(5,2)

  3. Varchar(4)

枚举类型

  1. Enum(‘female’,’male’)

  2. Set(‘book’,’football’,’A’….最多64)

约束条件

Null                         Default                        Extra

默认为允许                   默认null          

Not null                     default

 

    Key

    普通索引         index                 

    唯一索引         unique

    主键                   primary key

    外键                   foreign key

    全文索引         fulltext

    查看索引         desc 

                     showindex from  两者有何区别

          创建索引                            createindex xxx on table();

                                              UNIQUE INDEX 

          删除索引                            dropindex xxxx on table;

          建表指定索引字段        

          Primarykey        alter tablexxx modify xcolumn … primary key auto_increment

                            Altertable xxx add primary key();

                            删除注意事项,要先去掉auto_increment

                            Altertable xxxx drop primary key;

                           复合主键                            不同时重复,必须在建表是创建

                   Foreign key                        

                              1.存储引擎必须为innoDB

                              2.字段类型必须与匹配

                              3.被参考字段必须为索引字段

                              Foreignkey (字段) references (字段)

                              Onupdate cascade on delete on cascade) engine=innodb;


MySQL基础 三 数值类型,索引

原文:http://gxblue.blog.51cto.com/11326567/1767356

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!