Subscripted Expressions
AttentionThis page documents an earlier version. Go to the latest (v2.1)version.
Subscripted expression allows access to an element in a multi-element value such as a map collection by using operator []
. Subscripted column expressions can be used when writing the same way as a column expression. For example, if ids
refers to a column of type LIST
, ids[7]
refers to the third element of the list ids
, which can be set in an UPDATE statement.
- Subscripted expression can only be applied to columns of type
LIST
,MAP
, or user-defined datatypes. - Subscripting a
LIST
value with a non-positive index will yield NULL. - Subscripting a
MAP
value with a non-existing key will yield NULL. Otherwise, it returns the element value that is associated with the given key. - Apache Cassandra does not allow subscripted expression in the select list of the SELECT statement.
Examples
You can do this as shown below.
cqlsh:yugaspace> CREATE TABLE t(id INT PRIMARY KEY,yugamap MAP<TEXT, TEXT>);
cqlsh:yugaspace> UPDATE yugatab SET map_value['key_value'] = 'yuga_string' WHERE id = 7;
See Also
当前内容版权归 YugabyteDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 YugabyteDB .