本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
在 Amazon Keyspaces 中为表配置客户端时间戳
按照以下示例使用 Amazon Keyspaces、Cassandra 查询语言(CQL)或 Amazon Web Services Management Console,为现有表开启客户端时间戳。
- Console
-
为现有表打开客户端时间戳(控制台)
-
登录 Amazon Web Services Management Console并打开 Amazon Keyspaces 控制台:https://console.aws.amazon.com/msk/home
。 -
选择要更新的表,然后选择其他设置选项卡。
-
在其他设置选项卡上,前往修改客户端时间戳,然后选择打开客户端时间戳
选择保存更改以更改表的设置。
-
- Cassandra Query Language (CQL)
-
使用 CQL 语句
使用
ALTER TABLE
CQL 语句为现有表开启客户端时间戳。ALTER TABLE
my_table
WITH custom_properties = {'client_side_timestamps': {'status': 'enabled'}};;-
要确认新表的客户端时间戳设置,请使用
SELECT
语句查看custom_properties
,如以下示例所示。SELECT custom_properties from system_schema_mcs.tables where keyspace_name = '
my_keyspace
' and table_name = 'my_table
';此语句的输出显示了客户端时间戳的状态。
'client_side_timestamps': {'status': 'enabled'}
- Amazon CLI
-
使用 Amazon CLI
您可以使用以下示例,通过 Amazon CLI 为现有表开启客户端时间戳。
./aws keyspaces update-table \ --keyspace-name
my_keyspace
\ --table-namemy_table
\ --client-side-timestamps 'status=ENABLED'-
要确认表的客户端时间戳已打开,请运行以下代码。
./aws keyspaces get-table \ --keyspace-name
my_keyspace
\ --table-namemy_table
输出应类似于以下示例,且客户端时间戳的状态为
ENABLED
。{ "keyspaceName": "my_keyspace", "tableName": "my_table", "resourceArn": "arn:aws:cassandra:us-east-2:555555555555:/keyspace/my_keyspace/table/my_table", "creationTimestamp": 1662681312.906, "status": "ACTIVE", "schemaDefinition": { "allColumns": [ { "name": "id", "type": "int" }, { "name": "date", "type": "timestamp" }, { "name": "name", "type": "text" } ], "partitionKeys": [ { "name": "id" } ], "clusteringKeys": [], "staticColumns": [] }, "capacitySpecification": { "throughputMode": "PAY_PER_REQUEST", "lastUpdateToPayPerRequestTimestamp": 1662681312.906 }, "encryptionSpecification": { "type": "AWS_OWNED_KMS_KEY" }, "pointInTimeRecovery": { "status": "DISABLED" }, "clientSideTimestamps": { "status": "ENABLED" }, "ttl": { "status": "ENABLED" }, "defaultTimeToLive": 0, "comment": { "message": "" } }
使用客户端时间戳创建表
将客户端时间戳用于查询中