Updated on 2023-10-23 GMT+08:00

Binary Types

Table 1 lists the binary types supported by GaussDB.

Table 1 Binary types

Name

Description

Storage Space

BLOB

Binary large object (BLOB).

Currently, BLOB only supports the following external access interfaces:

  • DBE_LOB.GET_LENGTH
  • DBE_LOB.READ
  • DBE_LOB.WRITE
  • DBE_LOB.WRITE_APPEND
  • DBE_LOB.COPY
  • DBE_LOB.ERASE

For details about the APIs, see DBE_LOB.

NOTE:

Column storage cannot be used for the BLOB type.

The maximum value is 1,073,741,818 bytes (that is,1 GB minus 6 bytes).

RAW

Variable-length hexadecimal string.

NOTE:

Column storage cannot be used for the RAW type.

The maximum value is 1,073,741,818 bytes (that is,1 GB minus 6 bytes).

BYTEA

Variable-length binary string.

The maximum value is calculated as follows: 1 GB – (56 + 24 + 5 + 1 + Total number of bytes in the first n columns). For example, if the table is (a int, b bytea), the maximum storage length is 1 GB – 56 – 24 – 5 – 1 – 4(int) = 1073741735.

BYTEAWITHOUTORDERWITHEQUALCOL

Variable-length binary character string (new type for the encryption feature. If the encryption type of the encrypted column is specified as deterministic encryption, the column type is BYTEAWITHOUTORDERWITHEQUALCOL). The original data type is displayed when the encryption table is printed by running the meta command.

4 bytes plus the actual binary string. The maximum value is 1,073,741,771 bytes (1 GB minus 53 bytes).

BYTEAWITHOUTORDERCOL

Variable-length binary character string (new type for the encryption feature. If the encryption type of the encrypted column is specified as random encryption, the column type is BYTEAWITHOUTORDERCOL). The original data type is displayed when the encryption table is printed by running the meta command.

4 bytes plus the actual binary string. The maximum value is 1,073,741,771 bytes (1 GB minus 53 bytes).

_BYTEAWITHOUTORDERWITHEQUALCOL

Variable-length binary string, which is a new type for the encryption feature.

4 bytes plus the actual binary string. The maximum value is 1,073,741,771 bytes (1 GB minus 53 bytes).

_BYTEAWITHOUTORDERCOL

Variable-length binary string, which is a new type for the encryption feature.

4 bytes plus the actual binary string. The maximum value is 1,073,741,771 bytes (1 GB minus 53 bytes).

  • In addition to the size limitation on each column, the total size of each tuple is 1,073,741,771 bytes (1 GB minus 53 bytes).
  • BYTEAWITHOUTORDERWITHEQUALCOL, BYTEAWITHOUTORDERCOL, _BYTEAWITHOUTORDERWITHEQUALCOL, and _BYTEAWITHOUTORDERCOL cannot be directly used to create a table.

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- Create a table.
openGauss=# CREATE TABLE blob_type_t1 
(
    BT_COL1 INTEGER,
    BT_COL2 BLOB,
    BT_COL3 RAW,
    BT_COL4 BYTEA
) DISTRIBUTE BY REPLICATION;

-- Insert data.
openGauss=# INSERT INTO blob_type_t1 VALUES(10,empty_blob(),
HEXTORAW('DEADBEEF'),E'\\xDEADBEEF');

-- Query data in the table.
openGauss=# SELECT * FROM blob_type_t1;
 bt_col1 | bt_col2 | bt_col3  |  bt_col4   
---------+---------+----------+------------
      10 |         | DEADBEEF | \xdeadbeef
(1 row)

-- Drop the table.
openGauss=# DROP TABLE blob_type_t1;