

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 Amazon Keyspaces 中設定資料表的用戶端時間戳記
<a name="client-side-timestamps-existing-table"></a>

請依照這些範例，使用 Amazon Keyspaces AWS 管理主控台、Cassandra Query Language (CQL) 或 開啟現有資料表的用戶端時間戳記 AWS Command Line Interface。

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

**開啟現有資料表的用戶端時間戳記 （主控台）**

1. 登入 AWS 管理主控台，並在 https：//[https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home) 開啟 Amazon Keyspaces 主控台。

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": ""
       }
   }
   ```

------