如果想保留自增主键,可以改成非聚簇表,并指定SHARD_ROW_ID_BITS打散数据,比如:
CREATE TABLE t2_nonclustered_autoinc
(
id
bigint(20) NOT NULL PRIMARY KEY NONCLUSTERED AUTO_INCREMENT,
id2
bigint(20) DEFAULT NULL,
name
char(255) DEFAULT NULL,
varname
char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin SHARD_ROW_ID_BITS = 4 PRE_SPLIT_REGIONS=3;
1 个赞