tencent cloud

Feedback

CreateTable

Last updated: 2024-08-30 14:34:29

1. API Description

Domain name for API request: cdwdoris.tencentcloudapi.com.

This API is used to create a TCHouse-D table under the specified database.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: CreateTable.
Version Yes String Common Params. The value used for this API: 2021-12-28.
Region No String Common Params. This parameter is not required for this API.
InstanceId Yes String Resource ID, which is the TCHouse-D resource ID used for table creation.
DbName Yes String The database where the table is located; if it does not exist, create one.
TableName Yes String Name of the table to be created
KeysType Yes String Table data model:
AGG_KEY: aggregation model;
UNI_KEY: primary key model;
DUP_KEY: detail model
Columns.N Yes Array of Column Column information of the table
Distribution Yes Distribution Bucket information
UserName No String Use the user who has corresponding permissions for operations. If the TCHouse-D cluster uses a kernel account registered by a CAM user, you do not need to fill it in.
PassWord No String Password corresponding to the user. If the TCHouse-D cluster uses a kernel account registered by a CAM user, you do not need to fill it in.
IndexInfos.N No Array of IndexInfo Index information. The inverted index and N-Gram index can be configured through this parameter. The Prefix index is related to the sort key and key column, and do not require additional configuration. Configure bloom_filter_columns in the table attribute when BloomFilter index is required.
Partition No Partition Partition information
TableComment No String Table description
Properties.N No Array of Property Table attribute

3. Output Parameters

Parameter Name Type Description
Message String Note: This field may return null, indicating that no valid values can be obtained.
RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Creating a Table

This example shows you how to create a test table under the demo database.

Input Example

POST / HTTP/1.1
Host: cdwdoris.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateTable
<Common request parameters>

{
    "InstanceId": "cdwdoris-bjizjxxx",
    "DbName": "demo",
    "TableName": "test",
    "KeysType": "AGG_KEY",
    "Columns": [
        {
            "Name": "user_id",
            "Type": "LARGEINT",
            "IsNull": false,
            "IsKey": true,
            "IsPartition": false,
            "IsDistribution": true,
            "Comment": "User ID"
        },
        {
            "Name": "date",
            "Type": "DATE",
            "IsNull": false,
            "IsKey": true,
            "IsPartition": true,
            "IsDistribution": false,
            "Comment": "Date and time of data writing"
        },
        {
            "Name": "city",
            "Type": "VARCHAR(20)",
            "IsNull": true,
            "IsKey": true,
            "IsPartition": false,
            "IsDistribution": false,
            "Comment": "User's city"
        },
        {
            "Name": "last_visit_date",
            "Type": "DATETIME",
            "AggType": "REPLACE",
            "IsNull": false,
            "DefaultValue": "1970-01-01 00:00:00",
            "IsKey": false,
            "IsPartition": false,
            "IsDistribution": false,
            "Comment": "User's last access time"
        },
        {
            "Name": "cost",
            "Type": "BIGINT",
            "AggType": "SUM",
            "IsNull": false,
            "DefaultValue": "0",
            "IsKey": false,
            "IsPartition": false,
            "IsDistribution": false,
            "Comment": "User's total consumption"
        }
    ],
    "Partition": {
        "AutoPartition": false,
        "PartitionType": "Range",
        "RangeInfos": [
            {
                "RangeType": "LESS THAN",
                "PartitionName": "0201",
                "Max": "(\"2017-02-01\")"
            },
            {
                "RangeType": "FIXED",
                "PartitionName": "0202",
                "Left": "(\"2011-02-01\")",
                "Right": "(\"2012-02-01\")"
            }
        ]
    },
    "Distribution": {
        "DistributionType": "Hash",
        "Count": 3
    },
    "TableComment": "example",
    "Properties": [
        {
            "PropertyKey": "replication_allocation",
            "PropertyValue": "tag.location.default: 1"
        }
    ]
}

Output Example

{
    "Response": {
        "RequestId": "f8f5e0af-7d36-4b49-8b4d-9c103deef55a"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

There is no error code related to the API business logic. For other error codes, please see Common Error Codes.