问题描述

瀚高V9 mysql兼容模式下,进行like模糊匹配时,默认不支持忽略字符串大小写匹配,导致匹配失败,可通过设置collate值或修改字段表结构来处理。

解决方案

测试数据:

highgo=# select * from test;
id | name
----+---------
1 | Alice
2 | Bob
3 | Charlie

方案一:

highgo=# select * from test where name='bob' collate utf8_general_ci;
id | name
----+------
2 | Bob
(1 行记录)

方案二:

-- 查看表原结构
highgo=# show create table test;
Table | Create Table
-------+----------------------------
test | CREATE TABLE "test" ( +
| "id" integer NOT NULL,+
| "name" text +
| )
(1 行记录)

-- 修改表字段排序规则
highgo=# alter table test alter COLUMN name type varchar(100) collate utf8_general_ci;
ALTER TABLE
highgo=# select * from test where name='bob' ;
id | name
----+------
2 | Bob
(1 行记录)

highgo=# show create table test;
Table | Create Table
-------+-----------------------------------------------------------
test | CREATE TABLE "test" ( +
| "id" integer NOT NULL, +
| "name" character varying(100) COLLATE utf8_general_ci+
| )
(1 行记录)