Postgresql base64 编码 [英] Postgresql base64 encode

查看:225
本文介绍了Postgresql base64 编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to convert a db value into base64encode. I tried:

 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.

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

Where I am wrong? please help. thanks in advance

推荐答案

encode 函数将字节码编码为文本.

The encode function encodes from bytea to text.

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

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

这篇关于Postgresql base64 编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆