tencent cloud

腾讯云数据仓库 TCHouse-D

产品简介
产品概述
基本概念
集群架构
产品优势
应用场景
购买指南
计费概述
续费说明
到期与欠费说明
退费说明
配置变更计费说明
快速入门
通过控制台使用腾讯云数据仓库 TCHouse-D
通过客户端使用腾讯云数据仓库 TCHouse-D
操作指南
集群操作
监控和告警配置
账户权限管理
数据管理
查询管理
配置管理
节点管理
日志分析
SQL 工作区
开启资源隔离
开发指南
数据表设计
数据导入
数据导出
基础功能
查询优化
生态扩展功能
API 文档
History
Introduction
API Category
Making API Requests
Cluster Operation APIs
Database and Table APIs
Cluster Information Viewing APIs
Hot-Cold Data Layering APIs
Database and Operation Audit APIs
User and Permission APIs
Resource Group Management APIs
Data Types
Error Codes
云上生态
为子账号授予 CAM 策略
查询加速腾讯云 DLC
实践教程
基本功能使用
高级特性使用
资源规格选型及调优建议
命名规范及库表限制
表设计与数据导入
查询调优
建议规避的用法
通过 JDBC 方式公网访问 TCHouse-D
性能测试
TPC-H 性能测试
SSB 性能测试
TPC-DS 性能测试
常见问题
常见操作问题
常见报错
联系我们
词汇表
产品协议
服务等级协议
隐私政策
数据处理和安全协议

CreateTable

聚焦模式
字号
最后更新时间: 2025-10-30 21:32:16

1. API Description

Domain name for API request: cdwdoris.intl.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 - Aggregation Model

This example shows you how to create a table with the aggregation model.

Input Example

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

{
    "InstanceId": "cdwdoris-lrqz7cd4",
    "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 the data"
        },
        {
            "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,
            "IsKey": false,
            "DefaultValue": "1970-01-01 00:00:00",
            "IsPartition": false,
            "IsDistribution": false,
            "Comment": "The last visit time of the user"
        },
        {
            "Name": "cost",
            "Type": "BIGINT",
            "AggType": "SUM",
            "IsNull": false,
            "IsKey": false,
            "DefaultValue": "0",
            "IsPartition": false,
            "IsDistribution": false,
            "Comment": "Total cost of users"
        }
    ],
    "Distribution": {
        "DistributionType": "Hash",
        "Count": 3
    },
    "Partition": {
        "PartitionType": "Range",
        "AutoPartition": false,
        "RangeInfos": [
            {
                "RangeType": "LESS THAN",
                "PartitionName": "p201701",
                "Max": "(\"2017-02-01\")"
            },
            {
                "RangeType": "FIXED",
                "PartitionName": "a202",
                "Left": "(\"2017-02-02\")",
                "Right": "(\"2017-03-01\")"
            }
        ]
    },
    "TableComment": "example",
    "Properties": [
        {
            "PropertyKey": "replication_allocation",
            "PropertyValue": "tag.location.default: 1"
        }
    ]
}

Output Example

{
    "Response": {
        "Message": "",
        "RequestId": "feef710c-431d-443b-b5fb-bc7ca25bfafd"
    }
}

Example2 Creating a Table - Detailed Model

This example shows you how to create a table with the detailed model.

Input Example

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

{
    "InstanceId": "cdwdoris-lrqz7cd4",
    "DbName": "demo",
    "TableName": "dup_test",
    "KeysType": "DUP_KEY",
    "Columns": [
        {
            "Name": "timestamp",
            "Type": "DATETIME",
            "IsNull": false,
            "IsKey": true,
            "IsPartition": false,
            "IsDistribution": false,
            "Comment": "Log time"
        },
        {
            "Name": "type",
            "Type": "INT",
            "IsNull": false,
            "IsKey": true,
            "IsPartition": false,
            "IsDistribution": true,
            "Comment": "Log type"
        },
        {
            "Name": "error_code",
            "Type": "INT",
            "IsNull": true,
            "IsKey": true,
            "IsPartition": false,
            "IsDistribution": false,
            "Comment": "Error code"
        },
        {
            "Name": "error_msg",
            "Type": "VARCHAR(1024)",
            "IsNull": true,
            "IsKey": false,
            "IsPartition": false,
            "IsDistribution": false,
            "Comment": "Error message"
        },
        {
            "Name": "op_id",
            "Type": "BIGINT",
            "IsNull": true,
            "IsKey": false,
            "IsPartition": false,
            "IsDistribution": false,
            "Comment": "Operator ID"
        },
        {
            "Name": "op_time",
            "Type": "DATETIME",
            "IsNull": true,
            "Comment": "Processing time"
        }
    ],
    "Distribution": {
        "DistributionType": "Hash",
        "Count": 1
    },
    "Properties": [
        {
            "PropertyKey": "replication_allocation",
            "PropertyValue": "tag.location.default: 1"
        }
    ]
}

Output Example

{
    "Response": {
        "Message": "",
        "RequestId": "1b12e7c9-4802-412c-b23b-5a2514f508a8"
    }
}

Example3 Creating a Table - Primary Key Model

This example shows you how to create a table with the primary key model.

Input Example

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

{
    "InstanceId": "cdwdoris-lrqz7cd4",
    "DbName": "demo",
    "TableName": "uni_test1",
    "KeysType": "UNI_KEY",
    "Columns": [
        {
            "Name": "user_id",
            "Type": "LARGEINT",
            "IsNull": false,
            "IsKey": true,
            "IsPartition": false,
            "IsDistribution": true,
            "Comment": "User ID"
        },
        {
            "Name": "username",
            "Type": "VARCHAR(50)",
            "IsNull": false,
            "IsKey": true,
            "IsPartition": false,
            "IsDistribution": false,
            "Comment": "User nickname"
        },
        {
            "Name": "city",
            "Type": "VARCHAR(20)",
            "IsNull": true,
            "IsKey": false,
            "IsPartition": false,
            "IsDistribution": false,
            "Comment": "User's city"
        },
        {
            "Name": "age",
            "Type": "SMALLINT",
            "IsNull": true,
            "IsKey": false,
            "IsPartition": false,
            "IsDistribution": false,
            "Comment": "User's age"
        },
        {
            "Name": "sex",
            "Type": "TINYINT",
            "IsNull": true,
            "IsKey": false,
            "IsPartition": false,
            "IsDistribution": false,
            "Comment": "User's gender"
        },
        {
            "Name": "phone",
            "Type": "LARGEINT",
            "IsNull": true,
            "Comment": "User's phone number"
        },
        {
            "Name": "address",
            "Type": "VARCHAR(500)",
            "IsNull": true,
            "Comment": "User's address"
        },
        {
            "Name": "register_time",
            "Type": "DATETIME",
            "IsNull": true,
            "Comment": "User's registration time"
        }
    ],
    "Distribution": {
        "DistributionType": "Hash",
        "Count": 1
    },
    "Properties": [
        {
            "PropertyKey": "replication_allocation",
            "PropertyValue": "tag.location.default: 1"
        }
    ]
}

Output Example

{
    "Response": {
        "Message": "",
        "RequestId": "1e10c4a5-44cf-4833-be5b-cb5fb8217c43"
    }
}

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.

帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈