CARDINALITY
Description
The CARDINALITY function is used to calculate the number of elements in an array and the number of key-value pairs in a map.
Syntax
Parameter Description
array: The input array, with elements of typeT.map: The input map, consisting of key typeKand value typeV.
Return Type
- Returns an integer (
int), representing the number of elements in the array or the number of key-value pairs in the map.
Example
- Calculate the number of elements in the array:
- Calculate the number of key-value pairs in the map:
- Combine with actual data table operations:
Suppose there is a data table named
students, with the following table structure:
To insert a data entry into the students table:
Using the CARDINALITY function to calculate the number of hobbies of the student:
