postgresql 从 Db 读取字节作为字符串

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3767830/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-20 00:18:28  来源:igfitidea点击:

Reading bytes as a string from Db

postgresqlobjectbyte

提问by Mohan

I have one table that has 2 fields one(container_id) for numeric type and another for byte type(coDearntainer_objects) . I would like to read the byte field(container_objects) as a string for corresponding (container_id) field.

我有一张表,它有 2 个字段,一个 ( container_id) 用于数字类型,另一个用于字节类型 ( coDearntainer_objects)。我想将字节字段(container_objects)读取为相应(container_id)字段的字符串。

How could I do this? I am using Postgresql Db Table Structure:

我怎么能这样做?我正在使用 Postgresql Db 表结构:

CREATE TABLE container
(
  ct_id numeric,
  container_object bytea
)

回答by Frank Heikens

Take a look at encode()to transform a bytea to a string.

看看encode()将字节转换为字符串。