• 删除唯一性约束unique


    删除唯一性约束

    语法如下:

    alter table tableName drop index key_name;#删除唯一性约束,实际就是删除索引

    drop index key_name on tableName; #两种方法均可

    mysql> show create table t_user;
    +--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Table  | Create Table                                                                                                                                                                                                                     |
    +--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | t_user | CREATE TABLE `t_user` (
      `id` int(10) DEFAULT NULL,
      `name` varchar(32) NOT NULL,
      `email` varchar(128) DEFAULT NULL,
      UNIQUE KEY `name` (`name`,`email`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
    +--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    mysql> alter table t_user drop index name;
    mysql> show create table t_user;
    +--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Table  | Create Table                                                                                                                                                                               |
    +--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | t_user | CREATE TABLE `t_user` (
      `id` int(10) DEFAULT NULL,
      `name` varchar(32) NOT NULL,
      `email` varchar(128) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
    +--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
  • 相关阅读:
    为什么webstrom无法格式化代码?
    总结jq的一些特效
    欢迎自己入住博客
    JavaScript基础
    HTTP协议的概念作用和特点
    STM32(二十五)读写内部flash
    STM32(二十四)MDK编译过程以及文件类型全解
    STM32(二十三)RTC-实时时钟
    STM32(二十二)DAC输出正弦波
    STM32(二十一)SDIO-SD卡读写测试
  • 原文地址:https://www.cnblogs.com/xiangtingshen/p/10982032.html
Copyright © 2020-2023  润新知