postgresql - 函数 convert_from(character varying, unknown) 在 Postgres 中不存在

标签 postgresql

<分区>

当我尝试在下面的代码中将 unicode 转换为 utf8 时 发生“function convert_from(character varying, unknown) does not exist”错误。

select convert_from(artists, 'UTF8') from songs where     
to_tsvector('simple',convert_from(artists, 'UTF8')) 
  @@ plainto_tsquery('simple','alizee') 
limit 100

艺术家”列的类型为“TEXT”。

但是当我运行的时候

select convert_from(E'\u0422\u0438\u043c\u0430\u0442\u0438', 'UTF8');

效果不错。

我该如何解决这个问题? 我将不胜感激任何帮助。谢谢

最佳答案

来自 documentation : convert_from(string bytea, src_encoding name). 于是把美工投给bytea:

select convert_from(artists::bytea, 'UTF8') from songs where     
to_tsvector('simple',convert_from(artists, 'UTF8')) 
  @@ plainto_tsquery('simple','alizee') 
limit 100

关于postgresql - 函数 convert_from(character varying, unknown) 在 Postgres 中不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23659685/

相关文章:

postgresql - 如何禁用 SET search_path?

mysql - 根据可变条件选择多个单个(LIMIT 1)记录

database - Oracle Schema 疑问?

postgresql - 在 PostgreSQL 9.2 中重命名 hstore 键

sql - 寻找最高值(value)

java - 连接到 Cloud SQL : The Google Cloud SQL API is not enabled for project 上的 postgresql 实例

postgresql - docker容器启动时如何通过psql(-h localhost -p 5432)连接到postgres

python-3.x - 在使用 COPY 将大表读入 pandas 数据帧时使用参数化 SQL 查询

python - 一起使用 pytest fixtures 和 peewee transactions

sql - 如何高效查询带有标签的项目