readme.soundex

来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· SOUNDEX 代码 · 共 67 行

SOUNDEX
67
字号
NOTE: Modified August 07, 2001 by Joe Conway. Updated for accuracy	after combining soundex code into the fuzzystrmatch contrib---------------------------------------------------------------------The Soundex system is a method of matching similar sounding names(or any words) to the same code.  It was initially used by theUnited States Census in 1880, 1900, and 1910, but it has little usebeyond English names (or the English pronunciation of names), andit is not a linguistic tool.When comparing two soundex values to determine similarity, thedifference function reports how close the match is on a scalefrom zero to four, with zero being no match and four being anexact match.The following are some usage examples:SELECT soundex('hello world!');SELECT soundex('Anne'), soundex('Ann'), difference('Anne', 'Ann');SELECT soundex('Anne'), soundex('Andrew'), difference('Anne', 'Andrew');SELECT soundex('Anne'), soundex('Margaret'), difference('Anne', 'Margaret');CREATE TABLE s (nm text);INSERT INTO s VALUES ('john');INSERT INTO s VALUES ('joan');INSERT INTO s VALUES ('wobbly');INSERT INTO s VALUES ('jack');SELECT * FROM s WHERE soundex(nm) = soundex('john');SELECT a.nm, b.nm FROM s a, s b WHERE soundex(a.nm) = soundex(b.nm) AND a.oid <> b.oid;CREATE FUNCTION text_sx_eq(text, text) RETURNS boolean AS'select soundex($1) = soundex($2)'LANGUAGE SQL;CREATE FUNCTION text_sx_lt(text, text) RETURNS boolean AS'select soundex($1) < soundex($2)'LANGUAGE SQL;CREATE FUNCTION text_sx_gt(text, text) RETURNS boolean AS'select soundex($1) > soundex($2)'LANGUAGE SQL;CREATE FUNCTION text_sx_le(text, text) RETURNS boolean AS'select soundex($1) <= soundex($2)'LANGUAGE SQL;CREATE FUNCTION text_sx_ge(text, text) RETURNS boolean AS'select soundex($1) >= soundex($2)'LANGUAGE SQL;CREATE FUNCTION text_sx_ne(text, text) RETURNS boolean AS'select soundex($1) <> soundex($2)'LANGUAGE SQL;DROP OPERATOR #= (text, text);CREATE OPERATOR #= (leftarg=text, rightarg=text, procedure=text_sx_eq, commutator = #=);SELECT * FROM s WHERE text_sx_eq(nm, 'john');SELECT * FROM s WHERE s.nm #= 'john';SELECT * FROM s WHERE difference(s.nm, 'john') > 2;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?