OceanBase Database supports the map data type, which is used to store unordered key-value pairs. A map consists of keys and their corresponding values, allowing you to easily manage unordered key-value pairs, such as {a:1, b:2, c:3}. This data type is particularly useful in scenarios like storing configuration options, user attributes, and product information.
Currently, the map data type mainly supports Data Definition Language and Data Manipulation Language (DML) map data. You can create a map in two ways: by using a map expression or by constructing it from a string. Additionally, OceanBase Database provides two expressions, map_keys and map_values, which can extract arrays of keys or values from a map, making data processing and analysis more convenient.
The current version of OceanBase Database supports the following element types for map keys:
- Integer types:
TINYINT,SMALLINT,INT/INTEGER, andBIGINT, with support for theUNSIGNEDmodifier. - Floating-point types:
FLOATandDOUBLE. - String types:
VARCHAR.
The supported element types for map values are:
- Integer types:
TINYINT,SMALLINT,INT/INTEGER, andBIGINT, with support for theUNSIGNEDmodifier. - Floating-point types:
FLOATandDOUBLE. - String types:
VARCHAR. - Array types:
ARRAY.
Considerations and limitations:
- Comparison operators such as
<,>,>=, and<=are not supported. - Operations like
ORDER BY,GROUP BY, and aggregate functions such asMIN,MAX,AVG, andSUMare not supported. - The maximum nesting depth for arrays in map values is 6 levels.
In addition to the map data type, OceanBase Database also provides functions for handling map data. For more information, see Map functions.