gpt4 book ai didi

postgresql - 解析 COPY...WITH BINARY 结果

转载 作者:行者123 更新时间:2023-11-29 11:28:11 28 4
gpt4 key购买 nike

我正在使用这个:

COPY( select field1, field2, field3 from table ) TO 'C://Program Files/PostgreSql//8.4//data//output.dat' WITH BINARY

要将一些字段导出到文件,其中一个是 ByteA 字段。现在,我需要使用定制程序读取文件。

我如何解析这个文件?

最佳答案

COPY...BINARY 生成的文件的一般格式在 documentation 中有解释。 ,这很重要。

bytea 内容是最容易处理的,因为它们没有编码。

每个其他数据类型都有自己的编码规则,这些规则没有在文档中描述,而是在源代码中描述。来自文档:

To determine the appropriate binary format for the actual tuple data you should consult the PostgreSQL source, in particular the *send and *recv functions for each column's data type (typically these functions are found in the src/backend/utils/adt/ directory of the source distribution).

关于postgresql - 解析 COPY...WITH BINARY 结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14628179/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com