首页 > 数据库技术 > 详细

Mysql 自增列 主键

时间:2016-03-31 12:38:36      阅读:295      评论:0      收藏:0      [点我收藏+]

Mysql中假如有

ID Int auto_increment, CID varchar(36).

通常情况下都是 ID设置为主键。

假如要设置CID为主键。自增列ID必需是唯一索引。

create table Temp
(
   ID                   bigint not null auto_increment comment ‘编号‘,
   CID               varchar(36) not null,
   CreateTime           datetime not null default now() comment ‘创建时间‘,
   unique(ID),  --唯一索引
  primary key (CID) --主键
);
create index Index_CreateTime on TEMP --聚集索引
(
   CreateTime
);

  

Mysql 自增列 主键

原文:http://www.cnblogs.com/haoliansheng/p/5340610.html

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