Domain name for API request: dcdb.intl.tencentcloudapi.com.
This API is used to create an online DDL job.
A maximum of 20 requests can be initiated per second for this API.
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: CreateOnlineDDLJob. |
Version | Yes | String | Common Params. The value used for this API: 2018-04-11. |
Region | Yes | String | Common Params. For more information, please see the list of regions supported by the product. This API only supports: ap-beijing, ap-chengdu, ap-chongqing, ap-guangzhou, ap-hongkong, ap-jakarta, ap-mumbai, ap-nanjing, ap-seoul, ap-shanghai, ap-shanghai-fsi, ap-shenzhen-fsi, ap-singapore, ap-tokyo, eu-frankfurt, na-ashburn, na-siliconvalley. |
InstanceId | Yes | String | Instance ID |
Alter | Yes | String | Specifies the DDL statement to be executed. Common online DDL refer to this API documentation example section. |
DbName | Yes | String | Specifies the database to be modified. |
Table | Yes | String | Specifies the table to be modified. |
User | No | String | Specifies the account to execute DDL. Ensure the account has ALTER, CREATE, INSERT, UPDATE, DROP, DELETE, INDEX, CREATE TEMPORARY TABLES, LOCK TABLES, TRIGGER, REPLICATION CLIENT, REPLICATION SLAVE permissions. If not specified, the system account will be used by default. |
Password | No | String | Specifies the password for the account. |
CriticalLoad | No | Integer | Indicates that DDL will terminate if the number of running threads exceeds this value. Default is 58 if not specified. |
CheckAutoInc | No | Integer | Specifies whether to check auto-increment fields. If set to 1, modification of auto-increment fields is not allowed; if set to 0 or left empty, no check is performed. |
MaxDelay | No | Integer | Allowed primary-secondary delay time (in seconds). If set to 0 or left empty, do not check delay. |
UsePt | No | Integer | Indicates whether to use pt-osc tool for DDL. |
StartTime | No | String | Start Execution Time |
Parameter Name | Type | Description |
---|---|---|
FlowId | Integer | Online DDL task ID |
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. |
This example shows you how to add a field to test_tbl.
POST / HTTP/1.1
Host: dcdb.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateOnlineDDLJob
<Common request parameters>
{
"InstanceId": "tdsqlshard-h2yimmox",
"Alter": "alter table test_tbl add column test_add_col varchar(32) not null default 'test' comment 'test add col';",
"DbName": "test_db",
"Table": "test_tbl",
"CriticalLoad": 58,
"CheckAutoInc": 0,
"MaxDelay": 10,
"UsePt": 1,
"User": "test_user",
"Password": "test_pwd",
"StartTime": ""
}
{
"Response": {
"FlowId": 1140696,
"RequestId": "bd07e59f-dee8-4680-9a43-492a8a52c894"
}
}
This example shows you how to add an index to test_tbl.
This example shows you how to add a unique index: alter table test_tbl add unique key my_idx(id,name);
This example shows you how to add a regular index: alter table test_tbl add key my_idx_1(id,name);
POST / HTTP/1.1
Host: dcdb.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateOnlineDDLJob
<Common request parameters>
{
"InstanceId": "tdsql-4z38cfwj",
"Alter": "alter table test_tbl add unique key my_idx(id,name); ",
"DbName": "test_db",
"Table": "test_tbl",
"CriticalLoad": 58,
"CheckAutoInc": 0,
"MaxDelay": 10,
"UsePt": 1,
"User": "test_user",
"Password": "test_pwd",
"StartTime": ""
}
{
"Response": {
"FlowId": 1140697,
"RequestId": "c5afb15f-70c8-4e71-84b5-688dd326a8c3"
}
}
This example shows you how to delete the field test_add_col from test_tbl.
POST / HTTP/1.1
Host: dcdb.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateOnlineDDLJob
<Common request parameters>
{
"InstanceId": "tdsqlshard-h2yimmox",
"Alter": "alter table test_tbl drop column test_add_col; ",
"DbName": "test_db",
"Table": "test_tbl",
"CriticalLoad": 58,
"CheckAutoInc": 0,
"MaxDelay": 10,
"UsePt": 1,
"User": "test_user",
"Password": "test_pwd",
"StartTime": ""
}
{
"Response": {
"FlowId": 1140698,
"RequestId": "a9f824be-fc53-41f7-9e24-2aca60457331"
}
}
This example shows you how to modify the field test_add_col from varchar(32) to varchar(64) in the test_tbl table.
POST / HTTP/1.1
Host: dcdb.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateOnlineDDLJob
<Common request parameters>
{
"InstanceId": "tdsqlshard-h2yimmox",
"Alter": "alter table test_tbl modify column test_add_col varchar(64) not null default 'test' comment 'test change type'; ",
"DbName": "test_db",
"Table": "test_tbl",
"CriticalLoad": 58,
"CheckAutoInc": 0,
"MaxDelay": 10,
"UsePt": 1,
"User": "test_user",
"Password": "test_pwd",
"StartTime": ""
}
{
"Response": {
"FlowId": 1140699,
"RequestId": "7e2e0512-e429-4702-a9a6-d920eebd6536"
}
}
This example shows you how to optimize table space
POST / HTTP/1.1
Host: dcdb.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateOnlineDDLJob
<Common request parameters>
{
"InstanceId": "tdsqlshard-h2yimmox",
"Alter": "alter table test_tbl engine=innodb; ",
"DbName": "test_db",
"Table": "test_tbl",
"CriticalLoad": 58,
"CheckAutoInc": 0,
"MaxDelay": 10,
"UsePt": 1,
"User": "test_user",
"Password": "test_pwd",
"StartTime": ""
}
{
"Response": {
"FlowId": 1140701,
"RequestId": "9df10ff7-9db5-4cad-81e2-3ad742f7bc06"
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
Error Code | Description |
---|---|
InternalError.CreateFlowFailed | Failed to create a task workflow. |
InternalError.DbOperationFailed | Failed to query the database. |
InternalError.InnerSystemError | Internal system error. |
InvalidParameter.IllegalParameterError | Invalid parameters. |
ResourceUnavailable.InstanceStatusAbnormal | Incorrect database instance status. Operations are not allowed. |
UnsupportedOperation.InvalidOperation | Unsupported operation. |
Was this page helpful?