8.4. Binary Data Types

8.4. Binary Data Types
8.4.二进制数据类型
The bytea data type allows storage of binary strings; see Table 8.6.
bytea数据类型可存储二进制字符串;见表8.6.
A binary string is a sequence of octets (or bytes). Binary strings are distinguished from character  strings in two ways. First, binary strings specifically allow storing octets of value zero and other “nonprintable”  octets (usually, octets outside the decimal range 32 to 126). Character strings disallow zero  octets, and also disallow any other octet values and sequences of octet values that are invalid according  to the database's selected character set encoding. Second, operations on binary strings process the  actual bytes, whereas the processing of character strings depends on locale settings. In short, binary  strings are appropriate for storing data that the programmer thinks of as “raw bytes”, whereas character  strings are appropriate for storing text.
二进制字符串是八位字节(或字节)的序列。 二进制字符串与字符串有两种区别:首先,二进制字符串专门允许存储零值的八位位组和其他“不可打印的”八位位组(通常,八位位组的十进制范围在32到126之间)。字符串不允许使用零个八位字节,也不允许根据数据库的所选字符集编码而无效的任何其他八位字节值和八位字节值序列。其次,对二进制字符串的操作将处理实际的字节,而对字符串的处理则取决于语言环境设置。简而言之,二进制字符串适合于存储程序员认为是“原始字节”的数据,而字符串适合于存储文本。
 
The bytea type supports two formats for input and output: “hex” format and PostgreSQL's historical  “escape” format. Both of these are always accepted on input. The output format depends on the  configuration parameter bytea_output; the default is hex. (Note that the hex format was introduced in  PostgreSQL 9.0; earlier versions and some tools don't understand it.)
bytea类型支持两种格式的输入和输出:“hex”格式和PostgreSQL旧的“escape”格式。在输入中,这两种格式都可以使用。输出格式取决于bytea_output的设置;默认为hex(十六进制格式)。(注意,十六进制格式自PostgreSQL9.0引进;之前的版本并不能使用。)
 
The SQL standard defines a different binary string type, called BLOB or BINARY LARGE OBJECT . The input format is different from bytea , but the provided functions and operators are mostly the  same.
SQL标准定义了一个不同的二进制字符类型:BLOB或者BINARY LARGE OBJECT。输入格式虽然与bytea不一样,但是提供的函数及操作符几乎是一样的。
发布了341 篇原创文章 · 获赞 54 · 访问量 88万+

猜你喜欢

转载自blog.csdn.net/ghostliming/article/details/104629077