# AUTO_INCREMENT 属性

__*AUTO_INCREMENT*__
__*auto_increment_increment*__
__*auto_increment_offset*__
__*tidb_allow_remove_auto_inc*__

+ `AUTO_INCREMENT`: 是用于自动填充默认字段值的属性
  + 出于性能考虑,AUTO_INCREMENT 编号会以批量的形式分配给每个 TiDB Server 实例
  + 缓存批处理大小可以通过 **AUTO_ID_CACHE** 表选项控制
  + **LAST_INSERT_ID()** 可以获得上次插入操作时使用的值
```
tidb> show variables like 'auto_increment_%';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| ~!@auto_increment_increment@!~ | 1     |
| ~!@auto_increment_offset@!~    | 1     |
+--------------------------+-------+

tidb> show variables like 'tidb_allow_remove_auto_inc';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| tidb_allow_remove_auto_inc | OFF   |
+----------------------------+-------+
1 row in set (0.01 sec)
```
---------------------------------------------------------
注意:请尝试以下脚本以查看详细信息。
```
drop table if exists test.ar;

create table test.ar (id bigint primary key auto_increment, name char(30));

insert into test.ar (name) values ('AAA');

insert into test.ar (name) values ('AAA');

select * from test.ar;

select last_insert_id();

select * from information_schema.tables where table_name='ar' and table_schema='test'\G

```
