Binary Types
Table 1 lists the binary types supported by GaussDB.
Name |
Description |
Storage Space |
---|---|---|
BLOB |
Binary large object (BLOB). Currently, BLOB only supports the following external access APIs:
For details about the APIs, see DBE_LOB. |
For Ustore, the maximum size is 1 GB minus 1 byte. However, the size of the column description header and the size of the tuple (less than 1 GB minus 1 byte) where the column is located must also be considered. Therefore, the maximum size of the BLOB type may be less than 1 GB minus 1 byte. |
When sql_compatibility is set to 'MYSQL', if b_format_version is set to '5.7' and b_format_dev_version is set to 's1', the BLOB type is mapped to the BYTEA type, and the alias is BYTEA. |
For details about the storage specifications, see the BYTEA type. |
|
TINYBLOB MEDIUMBLOB LONGBLOB |
Binary large object (BLOB). |
For details about the storage specifications, see the BYTEA type. |
This type can be used only when sql_compatibility is set to 'MYSQL', b_format_version is set to '5.7', and b_format_dev_version is set to 's1'. The type is mapped to the BYTEA type, and the alias is BYTEA. |
||
RAW |
Variable-length hexadecimal string. |
4 bytes plus the actual binary string. The maximum size is 1 GB minus 1 byte. However, the size of the column description header and the size of the tuple (less than 1 GB minus 1 byte) where the column is located must also be considered. Therefore, the maximum size of this type may be less than 1 GB minus 1 byte. |
BYTEA |
Variable-length binary string. |
4 bytes plus the actual binary string. The maximum size is 1 GB minus 1 byte. However, the size of the column description header and the size of the tuple (less than 1 GB minus 1 byte) where the column is located must also be considered. Therefore, the maximum size of this type may be less than 1 GB minus 1 byte. |
BYTEAWITHOUTORDERWITHEQUALCOL |
Variable-length binary character string (new type for the encryption feature. If the encryption type of an encrypted column is specified as deterministic encryption, the column type is BYTEAWITHOUTORDERWITHEQUALCOL). The original data type is displayed when an encrypted 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 an encrypted column is specified as random encryption, the column type is BYTEAWITHOUTORDERCOL). The original data type is displayed when an encrypted 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 limit of each column, the total size of each tuple cannot exceed 1 GB minus 1 byte.
- BYTEAWITHOUTORDERWITHEQUALCOL, BYTEAWITHOUTORDERCOL, _BYTEAWITHOUTORDERWITHEQUALCOL, and _BYTEAWITHOUTORDERCOL cannot be directly used to create a table.
- RAW(n), where n indicates the recommended byte length and is not used to verify the byte length of the input raw type.
- When sql_compatibility is set to 'MYSQL', if b_format_version is set to '5.7' and b_format_dev_version is set to 's1', the TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB types are displayed as BYTEA. For example, when the table structure is queried, the TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB types are displayed as BYTEA.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
-- Create a table. gaussdb=# CREATE TABLE blob_type_t1 ( BT_COL1 INTEGER, BT_COL2 BLOB, BT_COL3 RAW, BT_COL4 BYTEA ) DISTRIBUTE BY REPLICATION; -- Insert data. gaussdb=# INSERT INTO blob_type_t1 VALUES(10,empty_blob(), HEXTORAW('DEADBEEF'),E'\\xDEADBEEF'); -- Query data in the table. gaussdb=# SELECT * FROM blob_type_t1; bt_col1 | bt_col2 | bt_col3 | bt_col4 ---------+---------+----------+------------ 10 | | DEADBEEF | \xdeadbeef (1 row) -- Drop the table. gaussdb=# DROP TABLE blob_type_t1; -- Example: TINYBLOB, MEDIUMBLOB, and LONGBLOB types gaussdb=# CREATE DATABASE gaussdb_m WITH dbcompatibility 'MYSQL'; gaussdb=# \c gaussdb_m -- Set compatible version control parameters. gaussdb_m=# SET b_format_version='5.7'; gaussdb_m=# SET b_format_dev_version='s1'; -- Create a table. gaussdb_m=# CREATE TABLE t1(num int, a tinyblob, b blob, m mediumblob, l longblob); -- Insert data. gaussdb_m=# INSERT INTO t1 VALUES (1, 'tinyblobtest', 'blobtest', 'mediumblobtest', 'longblobtest'); -- Query data in the table. gaussdb_m=# SELECT * FROM t1; num | a | b | m | l -----+--------------+----------+----------------+-------------- 1 | tinyblobtest | blobtest | mediumblobtest | longblobtest (1 row) -- Delete the table and database. gaussdb_m=# DROP TABLE t1; gaussdb_m=# \c postgres; gaussdb=# DROP DATABASE gaussdb_m; -- Reset parameters. gaussdb=# RESET ALL; |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot