MySql自增长列

1. 关键字

   auto_increment

2. 自增用法

   a) create table test(tid int auto_increment, tname varchar(10), primary key(tid));

   b) create table test(tid int auto_increment, tname varchar(10), primary key(tid)) auto_increment=10; 可以指定自增列的初始值

3. 获得当前自增列的值

   select @@identity;

4. 插入新值

   insert into test values(@identity, '小明');

posted on 2015-03-27 15:02  风付过款  阅读(158)  评论(0编辑  收藏  举报