Amazon Keyspaces 中的 Cassandra 查询语言 (CQL) 元素
了解 Amazon Keyspaces 支持的 Cassandra 查询语言 (CQL) 元素,包括标识符、常量、术语和数据类型。
标识符
标识符(或名称)用于标识表、列和其他对象。标识符可以带引号,也可以不带引号。以下情况将适用。
identifier ::= unquoted_identifier | quoted_identifier unquoted_identifier ::= re('[a-zA-Z][a-zA-Z0-9_]*') quoted_identifier ::= '"' (any character where " can appear if doubled)+ '"'
常量
定义以下常量。
constant ::= string | integer | float | boolean | uuid | blob | NULL string ::= '\'' (any character where ' can appear if doubled)+ '\'' '$$' (any character other than '$$') '$$' integer ::= re('-?[0-9]+') float ::= re('-?[0-9]+(\.[0-9]*)?([eE][+-]?[0-9+])?') | NAN | INFINITY boolean ::= TRUE | FALSE uuid ::= hex{8}-hex{4}-hex{4}-hex{4}-hex{12} hex ::= re("[0-9a-fA-F]") blob ::= '0' ('x' | 'X') hex+
条款
术语表示受支持的值的类型。术语由以下内容定义。
term ::= constant | literal | function_call | arithmetic_operation | type_hint | bind_marker literal ::= collection_literal | udt_literal | tuple_literal function_call ::= identifier '(' [ term (',' term)* ] ')' arithmetic_operation ::= '-' term | term ('+' | '-' | '*' | '/' | '%') term
数据类型
Amazon Keyspaces 支持以下数据类型:
字符串类型
数据类型 | 说明 |
---|---|
|
表示 ASCII 字符串。 |
|
表示 UTF-8 编码的字符串。 |
|
表示 UTF-8 编码的字符串( |
数字类型
数据类型 | 说明 |
---|---|
|
表示 64 位有符号长整型。 |
|
表示 64 位有符号整数计数器。有关更多信息,请参阅 计数器。 |
|
表示可变精度小数。 |
|
表示 64 位 IEEE 754 浮点。 |
|
表示 32 位 IEEE 754 浮点。 |
|
表示 32 位有符号整数。 |
|
表示任意精度的整数。 |
计数器
counter
列包含 64 位有符号整数。计数器值通过 UPDATE 语句进行递增或递减,并且无法直接设置。这使得 counter
列对于跟踪计数很有用。例如,您可以使用计数器来跟踪日志文件中的条目数或某个社交网络上的文章被查看的次数。以下限制适用于 counter
列:
-
类型
counter
的列不能是表的primary key
的一部分。 -
在包含一个或多个类型
counter
的列的表中,所有列的类型都必须为counter
。
如果计数器更新失败(例如,因超时或丢失与 Amazon Keyspaces 的连接导致失败),则客户端将不知道计数器值是否已更新。如果重试更新,则可能会再次应用对计数器值的更新。
Blob 类型
数据类型 | 说明 |
---|---|
|
表示任意字节。 |
布尔值类型
数据类型 | 说明 |
---|---|
|
表示 true 或 false 。
|
与时间相关的类型
数据类型 | 说明 |
---|---|
|
表示时间戳。 |
|
表示版本 1 UUID |
集合类型
数据类型 | 说明 |
---|---|
|
表示文本元素的有序集合。 |
|
表示键/值对的无序集合。 |
|
表示一个或多个文本元素的无序集合。 |
|
表示文本元素的有界组。 |
其他类型
数据类型 | 说明 |
---|---|
|
一个表示 IPv4 或 IPv6 格式的 IP 地址的字符串。 |