# AUTO_RANDOM 属性

__*AUTO_RANDOM*__
__*PK_AUTO_RANDOM_BITS*__

+ `AUTO_RANDOM`: 是一个字段属性,用于自动随机填充默认列值以解决热点问题
  + 仅支持 BIGINT 数据类型
  + 它是一个基于分片的随机生成器
  + `LAST_INSERT_ID()`:与 AUTO_INCREMENT 的情况类似,它检索上次插入操作所使用的值
+ e.g: `create table test.ar (id bigint primary key auto_random, name boolean);`
```
tidb> SELECT ~!@TIDB_ROW_ID_SHARDING_INFO@!~
   -> FROM ~!@information_schema.tables@!~
   -> WHERE table_name='ar' and table_schema='test';
+---------------------------+
| TIDB_ROW_ID_SHARDING_INFO |
+---------------------------+
| PK_AUTO_RANDOM_BITS=5     |
+---------------------------+
1 row in set (0.01 sec)
```
-------------------------------------------------------------
注意:请尝试以下脚本以查看详细信息。

```
drop table if exists test.ar;

drop table if exists test.dummy;

create table test.ar (id bigint primary key auto_random, name boolean);

insert into test.ar (name) values (null);

insert into test.ar (name) values (null);

select last_insert_id();

select distinct substr(id,1,14) from test.ar; 

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

