澳门比分网址二进制类型

所有澳门比分网址二进制类型都是八位字节的序列。它们用于将被认为是“原始”字节的数据存储,而不是适合存储文本的字符串。二进制类型值没有字符集或排序规则,并且基于存储字节的数值来完成排序和比较。在比较二进制类型值时,所有字节都很重要。

下表提供了对不同澳门比分网址二进制类型的简要说明和语法:

名称 描述 句法

斑点

二进制大物体

斑点

二进制

Fixed length binary data of length specified in bytes by parameter ( n ). Binary with no length parameter ( n ) specified is defined as a single byte (same as binary(1)). Binary values are not padded when stored. For example, a field declared BINARY(4) but an item inserted is only 3 bytes long, is stored as 3 bytes, not 4.

BINARY [(n)]

可变二进制

可变二进制 data types must be defined with a maximum length parameter ( n ). Variable Binary values are not padded when stored and their lengths vary, but cannot exceed the maximum length defined.

BINARY VARYING(n)
或者
VARBINARY(n)

存储二进制类型的值

斑点 values are stored separately from the rest of the contents of their row, and only a reference to the 斑点 value is kept in the row. 选择 statements which do not request the contents of the 斑点 字段不会加载它,并更改行中的其他字段不会导致 斑点 value to be rewritten. However, because it is stored separately it does take more time to retrieve the value when it is required. Even though 斑点 values are stored separately from the rest of the data in a row, they still participate in Multi-Version Concurrency Control (MVCC) and provide the same transactional consistency guarantees as other types.

BINARY and BINARY VARYING values are stored along with the rest of the row data in the table.

二进制输入格式

将文字插入二进制字段具有以下行为:

  • Inserting a integer literal (SMALLINT, INTEGER, BIGINT), either in base hex or decimal, will result in that number’S Big Endian二进制表示。仅使用表示数字所需的最小字节数。

  • 插入引用的字符串将导致字符串中每个字符的UTF-8字符值字符串。

在数字上下文中,十六进制值像整数一样。在字符串上下文(二进制和CHAR)中,十六进制值像二进制字符串一样,每对十六进制数字被转换为角色。

例子

CREATE TABLE bin_table (col_bin BINARY(3));
 INTO bin_table VALUES ('abc');
选择 * FROM bin_table;

 COL_BIN
 --------

  616263

 INTO bin_table VALUES (0x646F67);
选择 * FROM bin_table;

 COL_BIN
 --------

  616263
  646F67

选择 CAST(col_bin AS STRING) FROM bin_table;

 [CAST]
 -------

   abc
   dog