bytea的数据类型是什么,何时使用? [英] What is the datatype bytea and when would I use it?

查看:1149
本文介绍了bytea的数据类型是什么,何时使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Postgres中,有一个名为 bytea

In Postgres there is a datatype called bytea

的数据类型: http://www.postgresql.org/docs/9.0/static/datatype-binary.html

The Postgres docs are here for it: http://www.postgresql.org/docs/9.0/static/datatype-binary.html

我无法理解何时使用此功能-也无法真正理解此数据类型的用途。

I cannot understand when I would ever use this - nor can I really understand the purpose of this datatype.

我遇到过这个术语 bytea 几次,开始对自己感到奇怪:似乎他们希望我理解这一点……也许我应该找出它是什么。

I have come across this term bytea several times and starting to wonder to myself "It seems like they expect me to understand this... Maybe I should find out what it is."

如果有人可以给它一个简单的定义以及我何时可以使用它的某些给定情况,那将非常有帮助。

If anybody can give a simple definition for it and some given circumstance of when I would possibly use it, that would be super helpful.

谢谢。

推荐答案

我认为该文档对于 bytea text


二进制字符串与字符串有两种区别。首先,二进制字符串专门允许存储值为零的八位位组和其他不可打印的八位位组(通常,范围在32到126范围之外的八位位组)。字符串不允许使用零个八位字节,也不允许根据数据库的所选字符集编码而无效的任何其他八位字节值和八位字节值序列。其次,对二进制字符串的操作将处理实际的字节,而对字符串的处理则取决于语言环境设置。简而言之,二进制字符串适合存储程序员认为是原始字节的数据,而字符串适合存储文本。

Binary strings are distinguished from character strings in two ways. First, binary strings specifically allow storing octets of value zero and other "non-printable" octets (usually, octets outside the 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.

http://www.postgresql.org/docs/9.0/ static / datatype-binary.html

...这与内容是否为文本有关(取决于您的语言环境和国际化设置)已应用于您的服务器配置和运行它的操作系统)与八位字节(8位二进制值的序列,通常称为字节)的数组。

... it has to do with whether the contents are "text" (subject to the locale and internationalizations settings you've applied to your server configuration and the OS on which you're running it) vs. arrays of "octets" (sequences of 8-bit binary values --- commonly referred to as "bytes").

(术语字节和术语八位字节之间存在一些技术区别,因为历史上某些平台和计算设备使用带有奇偶校验和/或停止位的字节而八位位组一词始终精确地表示8位;引入该术语是为了澄清规格和文档r网络协议)。

(There are some technical distinctions between the term "byte" and the term "octet" -- because, historically, some platforms and computing devices used "bytes" with parity and/or stop bits while the term "octets" always means exactly 8-bits; a term that was introduced to clarify specifications and documentation for networking protocols).

这篇关于bytea的数据类型是什么,何时使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆