• Mysql中的primary key 与auto_increment


    mysql> create table cc(id int auto_increment);
    ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be def
    ined as a key
    mysql> create table cc(id int auto_increment primary key);
    Query OK, 0 rows affected (0.03 sec)
    
    mysql> desc cc;
    +-------+---------+------+-----+---------+----------------+
    | Field | Type    | Null | Key | Default | Extra          |
    +-------+---------+------+-----+---------+----------------+
    | id    | int(11) | NO   | PRI | NULL    | auto_increment |
    +-------+---------+------+-----+---------+----------------+
    1 row in set (0.01 sec)
    
    mysql>

    mysql> create table abc(id int primary key);
    Query OK, 0 rows affected (0.04 sec)

    mysql>

    注意:

    自动编号Auto_INCREMENT必须与主键PRIMARY KEY组合使用

    primary key可以独自使用

  • 相关阅读:
    12迭代器
    11(2)Vector(向量)
    11(1) LinkList ---链表
    11集合(Collection<E>) Arraylist
    10异常
    乘法计算过程的模拟
    10 Date详解
    详细的OA系统学习
    8 math类
    Java开发中的23种设计模式详解
  • 原文地址:https://www.cnblogs.com/perl6/p/7114677.html
Copyright © 2020-2023  润新知