

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# クライアント側のタイムスタンプが有効な新規テーブルを Amazon Keyspaces で作成する
<a name="client-side-timestamps-create-new-table"></a>

Amazon Keyspaces、Cassandra クエリ言語 (CQL) AWS マネジメントコンソール、または を使用して、クライアント側のタイムスタンプを有効にした新しい Amazon Keyspaces テーブルを作成するには、次の例に従います。 AWS Command Line Interface

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

**クライアント側のタイムスタンプが有効な新規テーブルを作成する (コンソール)**

1. にサインインし AWS マネジメントコンソール、[https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home) で Amazon Keyspaces コンソールを開きます。

1. ナビゲーションペインで [**Tables]** (テーブル) を選択して、[**Create table (テーブルの作成)**] を選択します。

1. [**Table details (テーブルの詳細)**] セクションの [**Create table (テーブルの作成)**] ページで、キースペースを選択し、新しいテーブルに名前を付けます。

1. [**Schema (スキーマ)**] セクションで、テーブルのスキーマを作成します。

1. [**Table settings (テーブルの設定)**] セクションで、[**Customize settings (設定のカスタマイズ)**] を選択します。

1. [**クライアント側のタイムスタンプ**] に進みます。

   [**クライアント側のタイムスタンプを有効にする**] を選択して、テーブルのクライアント側のタイムスタンプを有効にします。

1. [**Create table (テーブルの作成)**] を選択します。テーブルはクライアント側のタイムスタンプが有効の状態で作成されます。

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

**CQL を使用して新規テーブルを作成する**

1. クライアント側のタイムスタンプが有効な新規テーブルを CQL で作成するには、次の例を使用します。

   ```
   CREATE TABLE my_keyspace.my_table (
      userid uuid,
      time timeuuid,
      subject text,
      body text,
      user inet,
      PRIMARY KEY (userid, time)
   ) 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 keyspaces create-table \
   --keyspace-name my_keyspace \
   --table-name my_table \
   --client-side-timestamps 'status=ENABLED' \
   --schema-definition 'allColumns=[{name=id,type=int},{name=date,type=timestamp},{name=name,type=text}],partitionKeys=[{name=id}]'
   ```

1. 新しいテーブルのクライアント側のタイムスタンプが有効になっていることを確認するには、次のコードを実行します。

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

   この例のような出力が得られます。

   ```
   {
       "keyspaceName": "my_keyspace",
       "tableName": "my_table",
       "resourceArn": "arn:aws:cassandra:us-east-1:111122223333:/keyspace/my_keyspace/table/my_table",
       "creationTimestamp": 1662681206.032,
       "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": 1662681206.032
       },
       "encryptionSpecification": {
           "type": "AWS_OWNED_KMS_KEY"
       },
       "pointInTimeRecovery": {
           "status": "DISABLED"
       },
       "clientSideTimestamps": {
           "status": "ENABLED"
       },
       "ttl": {
           "status": "ENABLED"
       },
       "defaultTimeToLive": 0,
       "comment": {
           "message": ""
       }
   }
   ```

------