PostgreSQL 中 bytea 与 text 互相转换的函数有如下:
# 将 text 转为 bytea
cast ('bytes_text' as bytea) 或 'bytes_text'::bytea
# 将 bytea 转为 text
encode(bytes_text::bytea,‘escape’)
例如:
SELECT encode(bytes_,'escape') bytes_text FROM test_bytea;
End~
在PostgreSQL数据库中,可以使用cast或类型后缀::来将text转换为bytea,如bytes_text::bytea。反过来,利用encode函数配合escape选项可将bytea转换回text,例如SELECTencode(bytes_,escape)ASbytes_textFROMtest_bytea。
PostgreSQL 中 bytea 与 text 互相转换的函数有如下:
# 将 text 转为 bytea
cast ('bytes_text' as bytea) 或 'bytes_text'::bytea
# 将 bytea 转为 text
encode(bytes_text::bytea,‘escape’)
例如:
SELECT encode(bytes_,'escape') bytes_text FROM test_bytea;
End~

被折叠的 条评论
为什么被折叠?