1、 

    auto_increment:

                           innoDB 中 表中只可以有一个列是auto_increment的,这个列还一定要是索引。

    create table T(X int auto_increment primary key,Y int);               --  对

    create table T(X int auto_increment,Y int ,index ix_A (X))            --  错         用了auto_increment就可以这样加索引

    create table T(X int auto_increment,Y int auto_increment);          --  错         一个表只可以有一个auto_increment 列

    

    alter talbee T auto_increment = value ;   # value 的值要比表中的值大才行!

 

 

2、

   default:  

             它的值要么是常量、要么是now(),要么是current_date()

             create table T3(X int default 100,Y datetime default now()); 

 

             insert into T3(X,Y) values(default,default);

             insert into T3(X,Y) values(null,null);

             MYSQL auto_increment 、default 关键字

 

 

 

 

 

 

 

 

 

 

 

           

相关文章:

  • 2022-12-23
  • 2021-11-01
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2021-06-11
  • 2022-12-23
猜你喜欢
  • 2022-01-22
  • 2022-12-23
  • 2021-09-07
  • 2021-10-16
相关资源
相似解决方案