TiDB简述

TiDB不支持mysql一些特定语法,一些具体表现如下:

不支持将字段类型修改为其超集

例如不支持从 INTEGER 修改为 VARCHAR,或者从 TIMESTAMP 修改为 DATETIME,否则可能输出的错误信息 Unsupported modify column: type %d not match origin %d

例子:

alter table a_haiou_task modify alarm_sound varchar(8) null comment '布控任务告警声音';

报错:

Unsupported modify column: type varchar(8) not match origin int(11)

尚未支持“有损更改”。

同一类型小转大可以,大转小不行,例如:int(2)转int(4)

例子:

alter table `a_haiou_activiti_business` modify
`monitor_type` varchar(64) null comment '布控类型Code';

报错:

Unsupported modify column: length 64 is less than origin 126

不能在单条 ALTER TABLE 语句中完成多个操作

不能在单个语句中添加多个列或索引,否则,可能会输出 Unsupported multi schema change 的错误。

例子:

ALTER TABLE `a_haiou_tag`
ADD COLUMN `high_level_score` bigint(20) DEFAULT NULL COMMENT '高危分数阈值',
ADD COLUMN `middle_level_score` bigint(20) DEFAULT NULL COMMENT '疑似分数阈值';

报错:

Unsupported multi schema change

不支持添加/删除 CLUSTERED 类型的主键

例子:

alter table a_haiou_mac_task
	add constraint a_haiou_mac_task_pk
		primary key (ID);

报错:

Unsupported add primary key, alter-primary-key is false

不支持外键约束

其他

参考 官方文档