在 table1 中, column1的数据类型为字符串。但是,column1的值用拉丁文或西里尔文写。 IN table2 column1 仅在拉丁语中。在oracle中进行比较时,有什么方法可以将西里尔字母转换为拉丁字母。 这是我的simpe示例。注意:行数超过2500万。
搜索值仅匹配(如果值是西里尔字母,则转换为拉丁文并进行比较)
答案 0 :(得分:2)
declare
cyr_name nvarchar2(4000) := 'Стивен';
lat_name nvarchar2(4000) := 'Stiven';
translit nvarchar2(4000);
begin
translit := translate (upper(cyr_name),'АБВГДЕЗИЙКЛМНОПРСТУФЬЫЪЭ','ABVGDEZIJKLMNOPRSTUF''Y''E');
translit:= replace(translit, 'Ж', 'ZH');
translit:= replace(translit, 'Х', 'KH');
translit:= replace(translit, 'Ц', 'TS');
translit:= replace(translit, 'Ч', 'CH');
translit:= replace(translit, 'Ш', 'SH');
translit:= replace(translit, 'Щ', 'SH');
translit:= replace(translit, 'Ю', 'YU');
translit:= replace(translit, 'Я', 'YA');
dbms_output.put_line('LAT: '|| INITCAP(lat_name));
dbms_output.put_line('CYR: '|| INITCAP(cyr_name));
dbms_output.put_line('TRANSLIT: '|| INITCAP(translit));
--This function calculates the measure of agreement between two strings, and returns a score between 0 (no match) and 100 (perfect match).
dbms_output.put_line('Similarity: '|| UTL_MATCH.JARO_WINKLER_SIMILARITY(INITCAP(lat_name), INITCAP(translit)));
end;
输出:
LAT: Stiven
CYR: Стивен
TRANSLIT: Stiven
Similarity: 100