↑↓ 选择 ↵ 打开 ⌫ 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

百科 / 数据类型 / 其他内置类型

bytea

二进制数据(“字节数组”)

当前查看 PostgreSQL 18。

中文定义与说明

二进制数据(“字节数组”)

同版本中文手册定义

bytea1 或 4 字节外加真正的二进制串变长二进制串

查看完整中文手册与上下文。

PG10–20 核心源码清单。类型转换与操作符类列出源码显式声明的关系;缺少记录不能排除通过其他机制进行转换或使用索引。

定义

二进制数据(“字节数组”)

bytea
目录名称
pg_catalog.bytea
类型 OID
17
类型种类
基础类型
声明长度
变长(varlena)
存储策略
扩展
输入函数
byteain
输出函数
byteaout
手册中的声明
bytea
存储大小
1 或 4 字节,加上实际二进制串
手册说明
变长二进制串

系统目录属性

此构建的源码初始化值。字段含义参见 pg_type 。包含头文件默认值;依赖构建的常量保留符号形式,不作为服务器运行时实测。

oid
17
descr
variable-length string, binary values escaped
typacl
_null_
typlen
-1
typelem
0
typname
bytea
typsend
byteasend
typtype
b
typalign
i
typarray
0
typbyval
f
typdelim
','
typinput
byteain
typmodin
-
typndims
0
typowner
POSTGRES
typrelid
0
typmodout
-
typoutput
byteaout
typtypmod
-1
typanalyze
-
typdefault
_null_
typnotnull
f
typreceive
bytearecv
typstorage
x
typbasetype
0
typcategory
U
typcollation
0
typisdefined
t
typnamespace
pg_catalog
typsubscript
-
typdefaultbin
_null_
array_type_oid
1001
typispreferred
f
array_type_name
_bytea

类型转换 9

与此类型相关的显式 pg_cast 记录。PostgreSQL 还支持 pg_cast 之外的类型转换,缺少记录不能证明转换不可能。

源类型目标类型转换上下文转换方式函数
int2bytea显式函数bytea(int2)
int4bytea显式函数bytea(int4)
int8bytea显式函数bytea(int8)
byteaint2显式函数int2(bytea)
byteaint4显式函数int4(bytea)
byteaint8显式函数int8(bytea)
pg_ndistinctbytea隐式二进制兼容0
pg_dependenciesbytea隐式二进制兼容0
pg_mcv_listbytea隐式二进制兼容0

运算符重载 9

每种操作数签名均为独立重载。实现函数和返回类型来自同一源码构建。

运算符左操作数右操作数返回类型含义实现函数
=byteabyteabool等于。byteaeq
<>byteabyteabool不等于。byteane
<byteabyteabool小于。bytealt
<=byteabyteabool小于或等于。byteale
>byteabyteabool大于。byteagt
>=byteabyteabool大于或等于。byteage
~~byteabyteabool匹配 LIKE 表达式。bytealike
!~~byteabyteabool不匹配 LIKE 表达式。byteanlike
||byteabyteabytea连接。byteacat

操作符类 4

声明输入类型与此类型相符的操作符类。多态操作符类、类型转换和表达式索引还可能提供其他索引路径;不能仅凭此表判断是否支持索引。

操作符类索引方法输入类型操作符族默认存储类型
bytea_opsbtreebyteabtree/bytea_ops是与输入类型相同
bytea_opshashbyteahash/bytea_ops是与输入类型相同
bytea_minmax_opsbrinbyteabrin/bytea_minmax_ops是bytea
bytea_bloom_opsbrinbyteabrin/bytea_bloom_ops否bytea

版本比较

PostgreSQL 17 → 18。属性比较不包含构建标识和说明正文;原始目录字段与源描述保留原文。

类型转换

PostgreSQL 17

[{"castcontext": "i", "castfunc": "0", "castmethod": "b", "castsource": "pg_dependencies", "casttarget": "bytea"}, {"castcontext": "i", "castfunc": "0", "castmethod": "b", "castsource": "pg_mcv_list", "casttarget": "bytea"}, {"castcontext": "i", "castfunc": "0", "castmethod": "b", "castsource": "pg_ndistinct", "casttarget": "bytea"}]

PostgreSQL 18

[{"castcontext": "e", "castfunc": "bytea(int2)", "castmethod": "f", "castsource": "int2", "casttarget": "bytea"}, {"castcontext": "e", "castfunc": "bytea(int4)", "castmethod": "f", "castsource": "int4", "casttarget": "bytea"}, {"castcontext": "e", "castfunc": "bytea(int8)", "castmethod": "f", "castsource": "int8", "casttarget": "bytea"}, {"castcontext": "e", "castfunc": "int2(bytea)", "castmethod": "f", "castsource": "bytea", "casttarget": "int2"}, {"castcontext": "e", "castfunc": "int4(bytea)", "castmethod": "f", "castsource": "bytea", "casttarget": "int4"}, {"castcontext": "e", "castfunc": "int8(bytea)", "castmethod": "f", "castsource": "bytea", "casttarget": "int8"}, {"castcontext": "i", "castfunc": "0", "castmethod": "b", "castsource": "pg_dependencies", "casttarget": "bytea"}, {"castcontext": "i", "castfunc": "0", "castmethod": "b", "castsource": "pg_mcv_list", "casttarget": "bytea"}, {"castcontext": "i", "castfunc": "0", "castmethod": "b", "castsource": "pg_ndistinct", "casttarget": "bytea"}]

文档与源码

构建
18.6 · https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
指纹
555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f

相关条目

全部数据类型 · 下载此版本 JSON · 最早收录的样本不代表该类型的实际引入版本。