zoukankan      html  css  js  c++  java
  • MySQL添加数据库的唯一索引的几种方式~

    创建表时直接设置:

    DROP TABLE IF EXISTS `student`;
    CREATE TABLE `student` (
      `stu_id` int(11) NOT NULL AUTO_INCREMENT,
      `name` varchar(255) DEFAULT NULL,
      PRIMARY KEY (`stu_id`),
      UNIQUE KEY `UK_student_name` (`name`) 
    ) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;

     

     

    创建唯一索引:

    create unique index UK_student_name on student (name);

     

    建表后添加约束:

    alter table student add constraint uk_student_name unique (name);

  • 相关阅读:
    poj 2000
    poj1316
    poj1922
    poj2017
    poj1833 排列
    poj1338
    poj2136
    poj2242
    IE兼容html5标签
    绑定事件后,某些情况下需要解绑该事件
  • 原文地址:https://www.cnblogs.com/xiohao/p/5672781.html
Copyright © 2011-2022 走看看