微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Postgresql base64编码

我需要将db值转换为base64encode.我试过了:

select encode(cast(est_name as text),'base64') from establishments;

显示错误

[sql]select encode(string(cast(est_name as text)),'base64') from establishments;

[Err] ERROR:  function string(text) does not exist
LINE 1: select encode(string(cast(est_name as text)),'base64') from ...
                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

哪里错了?请帮忙.提前致谢

解决方法

编码功能从bytea编码为文本.

select encode(est_name::bytea,'base64') 
from establishments;

http://www.postgresql.org/docs/current/static/functions-binarystring.html#FUNCTIONS-BINARYSTRING-OTHER

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐