truncate表不能重置自增列

Viewed 37

MySQL的方式,truncate表会自动重置自增ID
doris的表现并不是

**版本号:**doris 2.1.3 selectdb 24.0.3
演示:
create table t2(id bigint not null auto_increment,k varchar(100) distributed by hash(id) buckets 32;
insert into t2 values(1,'asdfsd');
insert into t2 values(2,'asdfsd');
insert into t2 values(3,'asdfsd');
insert into t2 values(4,'asdfsd');
select * from t2; -- id到4
truncate table t2;
insert into t2(k) values('asdfsd');
insert into t2(k) values('asdfsd');
select * from t2;
第一行id 2
第二行id 40641(单独插入一行复现不了,插入2行数据会复现)

1 Answers

Doris 的自增ID 和 MYSQL的自增ID不同,Doris自增ID只保证唯一性