韩语的postgresql类似搜索
这是我的PostgreSQL的规范。
- X86_64-PC-Linux-gnu上的PostgreSQL 12.8,由GCC(GCC)4.8.5 20150623(Red Hat 4.8.5-11),64- bit
- Server_encoding:utf8
- client_encoding:utf8 client_encoding:utf8,
带有表'a',a',a'韩国人工作得很好。
SELECT * FROM a
WHERE name LIKE '%가%' escape '!'
-- result
seq name
001 가족
002 나가
003 가
但是,对于表“ B”,韩语的类似搜索根本不起作用,只有同等搜索显示结果。
SELECT * FROM b
WHERE name LIKE '%가%' escape '!'
-- result
no rows
首先,我怀疑数据库的编码,但是正如我在第一行中提到的服务器和客户端的编码相同的“ UTF8”。 此外,在相同情况下,表“ A”显示了完美的结果。 我不知道从哪里开始弄清楚这一点。 如果你们给我任何建议,将不胜感激。
Here is the specification of my PostgreSQL.
- PostgreSQL 12.8 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11), 64-bit
- server_encoding : UTF8
- client_encoding : UTF8
With table 'a', like-search by Korean works perfectly.
SELECT * FROM a
WHERE name LIKE '%가%' escape '!'
-- result
seq name
001 가족
002 나가
003 가
But with table 'b', like-search by Korean doesn't work at all and only equal-search shows results.
SELECT * FROM b
WHERE name LIKE '%가%' escape '!'
-- result
no rows
At the first look, I suspected the encoding of the database but as I mentioned in the first line the encodings of the server and client are the same 'UTF8'.
Furthemore, in the same condition the table 'a' shows perfect results.
I don't know where to start to figure this out..
If you guys give me any suggestion it would be super appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
伙计们终于发现了根问题。
该列在Where子句中的列“名称”应该保存上传文件的名称。该文件是在Mac中生成的,这是问题所在。
如果文件的名称为'한글',在韩语中表示韩语,则应像'한글'一样显示和存储,但在Mac中显示在屏幕上,但实际上存储在db中,如'ㅎㅏㄴㄱㅡㄹ' 。
guys finally I found the root problem.
The column 'name' in the where clause was supposed to save a name of an uploaded file. The file was generated in MAC and this is the problem.
If the name of the file is '한글' which means Korean in Korean, it should be displayed and stored like '한글' but in MAC it shows '한글' on the screen but stored in the DB like 'ㅎㅏㄴㄱㅡㄹ' actually.