问题现象
在对存在向量索引的表进行 drop column 时,出现报错 ERROR 1235,具体示例如下。
创建测试表 tbl_doc_emb。
obclient> CREATE TABLE `tbl_doc_emb` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`kb_id` varchar(256) NOT NULL COMMENT '知识库ID',
`doc_id` varchar(255) NOT NULL COMMENT '文档ID',
`metadata` text DEFAULT NULL COMMENT '元数据',
`content` text NOT NULL COMMENT '文件内容',
`vector_1024` VECTOR(1024) DEFAULT NULL COMMENT '文件内容向量化,1024 维',
`vector_3072` VECTOR(3072) DEFAULT NULL COMMENT '文件内容向量化',
`status` tinyint(1) DEFAULT NULL COMMENT '删除状态 0-正常 1-删除',
`create_time` bigint(20) DEFAULT NULL COMMENT '创建时间',
`update_time` bigint(20) DEFAULT NULL COMMENT '更新时间',
`created_by` varchar(32) NOT NULL COMMENT '创建人',
PRIMARY KEY (`id`),
VECTOR KEY `idx_content_vec` (`vector_3072`) WITH (DISTANCE=COSINE, TYPE=HNSW, LIB=VSAG, M=16, EF_CONSTRUCTION=200, EF_SEARCH=64) BLOCK_SIZE 16384,
VECTOR KEY `idx_vector_1024` (`vector_1024`) WITH (DISTANCE=COSINE, TYPE=HNSW, LIB=VSAG, M=16, EF_CONSTRUCTION=200, EF_SEARCH=64) BLOCK_SIZE 16384,
KEY `idx_kb_id` (`kb_id`) BLOCK_SIZE 16384 LOCAL,
KEY `idx_doc_id` (`doc_id`) BLOCK_SIZE 16384 LOCAL
) AUTO_INCREMENT = 23976 AUTO_INCREMENT_MODE = 'ORDER' DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 3 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 COMMENT = '文档向量表';
执行 drop column 一个普通字段的时候报如下错误
obclient> alter table tbl_doc_emb drop column `metadata`;
ERROR 1235 (0A000): Run this DDL operation on table with fulltext/multivalue/vector index. not supported
适用版本
OceanBase 数据库 V4.3.3 至 V4.3.5.2 之间版本。
问题原因
OceanBase 数据库从 V4.3.3 版本开始支持向量类型,在 V4.3.5.2 之前的版本中向量索引,未放开 offline ddl。而 drop column 属于 offline ddl,当前的表中有向量索引,所以被限制了。
解决方法
临时先删除向量索引,再删除需要 drop column 的 (metadata) 字段。
obclient> alter table tbl_doc_emb drop index idx_content_vec; Query OK, 0 rows affected (3.133 sec) obclient> alter table tbl_doc_emb drop index idx_content_vec; Query OK, 0 rows affected (4.475 sec) obclient> alter table tbl_doc_emb drop column metadata; Query OK, 0 rows affected (4.334 sec)升级 OceanBase 数据库版本到 V4.3.5.2 及其更高的版本。