甲骨文版本:11.2.0.2.0
我已经设置NLS_COMP = 'LINGUISTIC'
和NLS_SORT = 'BINARY_CI'
.
每当我使用LIKE
没有前导通配符 (%) 的比较时,它都不会返回正确的结果。这是一个通用示例。我的问题显然与查询#3 有关。以前有人经历过吗?
CREATE TABLE People
(
ID NUMBER(1,0),
FirstName NVARCHAR2(20),
LastName NVARCHAR2(20)
);
INSERT INTO People (ID, FirstName, LastName) VALUES ('1', 'John', 'Doe');
INSERT INTO People (ID, FirstName, LastName) VALUES ('2', 'Jane', 'Doe');
INSERT INTO People (ID, FirstName, LastName) VALUES ('3', 'Rich', 'Donner');
INSERT INTO People (ID, FirstName, LastName) VALUES ('4', 'Mike', 'Redoer');
-- Query #1
SELECT ID FROM People WHERE Lastname = 'doe';
-- Results (Correct)
-- 1
-- 2
-- Query #2
SELECT ID FROM People WHERE Lastname LIKE '%doe%';
-- Results (Correct)
-- 1
-- 2
-- 4
-- Query #3
SELECT ID FROM People WHERE Lastname LIKE 'do%';
-- Results (Incorrect)
-- 1
-- 2
-- 3
-- 4