

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 在 Amazon Keyspaces 中为表配置客户端时间戳
<a name="client-side-timestamps-existing-table"></a>

按照以下示例，使用 Amazon Keyspaces、Cassandra 查询语言 (CQL) AWS 管理控制台或，为现有表开启客户端时间戳。 AWS Command Line Interface

------
#### [ Console ]

**为现有表打开客户端时间戳（控制台）**

1. [登录并在家中打开 Amazon Keyspaces 控制台。 AWS 管理控制台 https://console.aws.amazon.com/keyspaces/](https://console.aws.amazon.com/keyspaces/home)

1. 选择要更新的表，然后选择**其他设置**选项卡。

1. 在**其他设置**选项卡上，前往**修改客户端时间戳**，然后选择**打开客户端时间戳**

1. 选择**保存更改**以更改表的设置。

------
#### [ Cassandra Query Language (CQL) ]

**使用 CQL 语句**

1. 使用 `ALTER TABLE` CQL 语句为现有表开启客户端时间戳。

   ```
   ALTER TABLE my_table WITH custom_properties = {'client_side_timestamps': {'status': 'enabled'}};;
   ```

1. 要确认新表的客户端时间戳设置，请使用 `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'}
   ```

------
#### [ AWS CLI ]

**使用 AWS CLI**

1. 您可以使用以下示例为现有表启用客户端时间戳。 AWS CLI 

   ```
   ./aws keyspaces update-table \
   --keyspace-name my_keyspace \
   --table-name my_table \
   --client-side-timestamps 'status=ENABLED'
   ```

1. 要确认表的客户端时间戳已打开，请运行以下代码。

   ```
   ./aws keyspaces get-table \
   --keyspace-name my_keyspace \
   --table-name my_table
   ```

   输出应类似于以下示例，且客户端时间戳的状态为 `ENABLED`。

   ```
   {
       "keyspaceName": "my_keyspace",
       "tableName": "my_table",
       "resourceArn": "arn:aws:cassandra:us-east-1:111122223333:/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": ""
       }
   }
   ```

------