# Auto_Increment Attribute

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

+ `AUTO_INCREMENT`: is the attribute used to automatically populate the default column value
  + For performance reasons, AUTO_INCREMENT numbers are assigned to each TiDB Server instance in batches
  + Cache batch size can be controlled by the**AUTO_ID_CACHE** table option
  + **LAST_INSERT_ID () ** You can get the value used in the last insert operation
```
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)
```
------------------------------------------------------------

Class demo scripts:

https://github.com/pingcap/tidb-course-201-lab/blob/master/scripts/07-demo-auto-increment-01-show.sql

https://github.com/pingcap/tidb-course-201-lab/blob/master/scripts/07-demo-auto-increment-02-show.sh

https://github.com/pingcap/tidb-course-201-lab/blob/master/scripts/07-demo-auto-increment-03-show.sh

Note: Please try the following script to see the details.
```
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

```
