You need to enable JavaScript to run this app.
文档中心
云数据库 TiDB 版

云数据库 TiDB 版

复制全文
下载 pdf
导入任务管理
CreateImportTask - 创建导入任务
复制全文
下载 pdf
CreateImportTask - 创建导入任务
调用 CreateImportTask 接口创建导入任务。​
调试​
API Explorer
您可以通过 API Explorer 在线发起调用,无需关注签名生成过程,快速获取调用结果。
​
请求参数​
下方仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数。​
Action string 必选 示例值:CreateImportTask​
要执行的操作,取值:CreateImportTask。​
​
Version string 必选 示例值:2026-06-30​
API的版本,取值:2026-06-30。​
​
ImportOptions object 可选 示例值:{ "CompatibleId": "1237589******", "CompletePercent": 0, "CreateTime": "2026-10-29T06:21:38Z", "CreationDetails": { "ImportOptions": { "CsvFormat": { "BackslashEscape": true, "Delimiter": "\"", "Header": true, "NotNull": false, "NullValue": "\\N", "Separator": ",", "TrimLastSeparator": false }, "FileType": "CSV", "NeedDropTable": false }, "Source": { "Tos": { "AccessKey": { "Id": "AK****MzJhMTYyNG******" }, "AuthType": "ACCESS_KEY", "Uri": "tos://test-tidb/CVS/" }, "Type": "TOS" } }, "ImportId": "imp-pcl3bpqlabadlp7lw3a5******", "InstanceId": "tidb-46e1eca920******", "PostImportCompletedPercent": 0, "State": "PREPARING", "TotalSize": "0", "TotalTablesCount": 0 }​
导入选项。​
NeedDropTable boolean 可选 示例值:true​
是否先删除目标表(仅 tutorial 场景使用)。取值如下:​
  • true:删除。​
  • false:不删除。​
​
FileType string 可选 示例值:SQL​
数据格式。取值如下:​
  • CSV:CSV 格式。​
  • Parquet:Parquet 格式。​
  • AURORA_SNAPSHOT:AURORA_SNAPSHOT 格式。​
  • SQL:SQL 格式。​
​
CsvFormat object 可选​
CSV 格式配置。​
Header boolean 可选 示例值:true​
是否包含首行表头。取值如下:​
  • true:包含。​
  • false:不包含。​
​
NotNull boolean 可选 示例值:true​
是否禁止列为 NULL。取值如下:​
  • true:禁止。​
  • false:不禁止。​
​
NullValue string 可选 示例值:\\N​
NULL 的字符串表示。​
​
BackslashEscape boolean 可选 示例值:true​
是否转义反斜杠。取值如下:​
  • true:转义。​
  • false:不转义。​
​
TrimLastSeparator boolean 可选 示例值:true​
是否去除行尾多余分隔符。取值如下:​
  • true:去除。​
  • false:不去除。​
​
Separator string 可选 示例值:,​
列分隔符。​
​
Delimiter string 可选 示例值:\"​
包裹符。​
​
​
​
Source object 必选 示例值:{ "Type": "TOS", "Tos": { "Uri": "tos://tidb-import-bucket/user_source_data/", "AuthType": "ACCESS_KEY", "AccessKey": { "Id": "AKLTNGRlYWNiMzJhMTYy******", "Secret": "TWpVME9HUTBOR0UzT0Rk******" } }, "TargetTableInfos": [ { "TargetTable": { "Database": "biz_user_db", "Table": "user_info" }, "CustomFile": "user_202609.csv" } ], "Local": { "UploadId": "upload-882fa31e-76b2-4411-b721******", "TargetDatabase": "biz_local_db", "TargetTable": "local_temp_table", "FileName": "local_sample.csv", "Columns": [ { "ColumnName": "id", "ColumnType": "BIGINT UNSIGNED" }, { "ColumnName": "user_name", "ColumnType": "VARCHAR(64)" }, { "ColumnName": "create_time", "ColumnType": "DATETIME" } ], "PkColumns": [ "id" ] } }​
导入数据源配置。​
Type string 可选 示例值:TOS​
数据源类型。 Essential 计划支持 TOS 和 Local。​
​
Tos object 可选​
TOS 源配置。​
Uri string 可选​
TOS URI。​
​
AuthType string 可选​
固定为 ACCESS_KEY。​
​
AccessKey object 可选​
访问凭证。​
说明​
如何获取 AccessKey ID 及 AccessKey Secret,请参见 Access Key(密钥)管理。​
Id string 可选​
AccessKey ID。​
​
Secret string 可选​
AccessKey Secret。​
​
​
​
TargetTableInfos object[] 可选​
导入目标表信息。​
TargetTable object 可选​
目标表信息。​
Database string 可选​
数据库名。​
​
Table string 可选​
表名。​
​
​
CustomFile string 可选​
自定义文件,为空时使用默认规则导入数据。​
​
​
Local object 可选​
本地文件导入源配置。​
UploadId string 可选​
上传文件的 upload_id。​
​
TargetDatabase string 可选​
目标数据库。​
​
TargetTable string 可选​
目标表。​
​
FileName string 可选​
导入文件名(只读)。​
​
Columns object[] 可选​
目标表列定义(仅输入,目标表不存在时用于建表)。​
ColumnName string 可选​
列名。​
​
ColumnType string 可选​
列类型。​
​
​
PkColumns string[] 可选​
主键列(仅输入)。​
​
​
​
ProjectName string 可选 示例值:default​
项目名称。​
​
InstanceId string 必选 示例值:tidb-544c96a2******​
目标实例 ID。​
​
​
​
返回参数​
下方仅列出本接口特有的返回参数。更多信息请参见返回结构。​
Import_ object 示例值:{ "InstanceId": "tidb-544c96a2******", "CompatibleId": "1237***", "CompletePercent": 0, "CreateTime": "2026-09-30T08:56:33Z", "CreationDetails": { "ImportOptions": { "CsvFormat": { "BackslashEscape": true, "Delimiter": "\"", "Header": true, "NotNull": false, "NullValue": "\\N", "Separator": ",", "TrimLastSeparator": false }, "FileType": "CSV", "NeedDropTable": false }, "Source": { "Tos": { "AccessKey": { "Id": "AKLTNGRlYWNiMzJhMTYy******" }, "AuthType": "ACCESS_KEY", "Uri": "tos://test-tidb/CVS/" }, "Type": "TOS" } }, "ImportId": "imp-rqnomxhdqzeo5gkiij******", "Name": "import_2026-09-30T08:56:33Z", "PostImportCompletedPercent": 0, "State": "PREPARING", "TotalSize": "0", "TotalTablesCount": 0 }​
创建成功的导入任务信息。​
ImportId string​
导入任务 ID。​
​
TotalSize string​
待导入数据总大小(uint64 字符串)。​
​
CreateTime string​
创建时间。​
​
CompleteTime string​
完成时间。​
​
State string​
导入状态。​
​
CompletePercent integer​
完成百分比。​
​
Message string​
失败时的错误信息。​
​
CreationDetails object​
创建时配置详情。​
ImportOptions object​
导入选项。​
NeedDropTable boolean 示例值:true​
是否先删除目标表(仅 tutorial 场景使用)。取值如下:​
  • true:删除。​
  • false:不删除。​
​
FileType string 示例值:SQL​
数据格式。取值如下:​
  • CSV:CSV 格式。​
  • Parquet:Parquet 格式。​
  • AURORA_SNAPSHOT:AURORA_SNAPSHOT 格式。​
  • SQL:SQL 格式。​
​
CsvFormat object​
CSV 格式配置。​
Header boolean 示例值:true​
是否包含首行表头。取值如下:​
  • true:包含。​
  • false:不包含。​
​
NotNull boolean 示例值:true​
是否禁止列为 NULL。取值如下:​
  • true:禁止。​
  • false:不禁止。​
​
NullValue string 示例值:\\N​
NULL 的字符串表示。​
​
BackslashEscape boolean 示例值:true​
是否转义反斜杠。取值如下:​
  • true:转义。​
  • false:不转义。​
​
TrimLastSeparator boolean 示例值:true​
是否去除行尾多余分隔符。取值如下:​
  • true:去除。​
  • false:不去除。​
​
Separator string 示例值:,​
列分隔符。​
​
Delimiter string 示例值:\"​
包裹符。​
​
​
​
Source object​
数据源配置。​
Type string 示例值:TOS​
数据源类型。 Essential 计划支持 TOS 和 Local。​
​
Tos object​
TOS 源配置。​
Uri string​
TOS URI。​
​
AuthType string​
固定为 ACCESS_KEY。​
​
AccessKey object​
访问凭证。​
说明​
如何获取 AccessKey ID 及 AccessKey Secret,请参见 Access Key(密钥)管理。​
Id string​
AccessKey ID。​
​
Secret string​
AccessKey Secret。​
​
​
​
TargetTableInfos object[]​
导入目标表信息。​
TargetTable object​
目标表信息。​
Database string​
数据库名。​
​
Table string​
表名。​
​
​
CustomFile string​
自定义文件,为空时使用默认规则导入数据。​
​
​
Local object​
本地文件导入源配置。​
UploadId string​
上传文件的 upload_id。​
​
TargetDatabase string​
目标数据库。​
​
TargetTable string​
目标表。​
​
FileName string​
导入文件名(只读)。​
​
Columns object[]​
目标表列定义(仅输入,目标表不存在时用于建表)。​
ColumnName string​
列名。​
​
ColumnType string​
列类型。​
​
​
PkColumns string[]​
主键列(仅输入)。​
​
​
​
​
AllCompletedTables object[]​
已完成的表信息。​
TableName string​
表名。​
​
Result string​
导入结果。​
​
Message string​
导入信息。​
​
DataFilePattern string​
数据文件匹配规则。​
​
​
PostImportCompletedPercent integer 示例值:100​
数据导入后的整体校验进度。​
​
CompatibleId string​
兼容 dataflow-svc v1beta OPENAPI 的 uint64 标识(字符串)。​
​
StartTime string 示例值:2026-10-21T08:54:12Z​
导入开始时间。​
​
TotalTablesCount integer 示例值:2​
导入表总数。​
​
InstanceId string​
目标实例 ID。​
​
​
​
​
请求示例​
​
POST /?Action=CreateImportTask&Version=2026-06-30 HTTP/1.1​
Accept: application/json​
Content-Type: application/json​
Host: tidb.cn-beijing.volcengineapi.com​
X-Date: 20260728T000000Z​
Authorization: HMAC-SHA256 Credential=AK****/20260728/cn-beijing/tidb/request, SignedHeaders=accept;content-type;host;x-date, Signature=****​
​
{​
"ProjectName": "default",​
"InstanceId": "tidb-46e1ec******",​
"ImportOptions": {​
"FileType": "CSV",​
"CsvFormat": {​
"Separator": ",",​
"Delimiter": "\"",​
"Header": true,​
"NotNull": false,​
"NullValue": "\\N",​
"BackslashEscape": true,​
"TrimLastSeparator": false​
}​
},​
"Source": {​
"Type": "TOS",​
"Tos": {​
"Uri": "tos://test-tidb/CVS/",​
"AuthType": "ACCESS_KEY",​
"AccessKey": {​
"Id": "AKLTNGRlYWNiMzJh********",​
"Secret": "TW********"​
}​
}​
}​
}​
​
返回示例​
​
{​
"ResponseMetadata": {​
"RequestId": "20261029142137531AD44C54E4A29B3******",​
"Action": "CreateImportTask",​
"Version": "2026-06-30",​
"Service": "tidb",​
"Region": "cn-beijing"​
},​
"Result": {​
"Import_": {​
"CompatibleId": "1237589******",​
"CompletePercent": 0,​
"CreateTime": "2026-10-29T06:21:38Z",​
"CreationDetails": {​
"ImportOptions": {​
"CsvFormat": {​
"BackslashEscape": true,​
"Delimiter": "\"",​
"Header": true,​
"NotNull": false,​
"NullValue": "\\N",​
"Separator": ",",​
"TrimLastSeparator": false​
},​
"FileType": "CSV",​
"NeedDropTable": false​
},​
"Source": {​
"Tos": {​
"AccessKey": {​
"Id": "AK****MzJhMTYyNG******"​
},​
"AuthType": "ACCESS_KEY",​
"Uri": "tos://test-tidb/CVS/"​
},​
"Type": "TOS"​
}​
},​
"ImportId": "imp-pcl3bpqlabadlp7lw3a5******",​
"InstanceId": "tidb-46e1eca920******",​
"PostImportCompletedPercent": 0,​
"State": "PREPARING",​
"TotalSize": "0",​
"TotalTablesCount": 0​
}​
}​
}​
​
错误码​
下表为您列举了该接口与业务逻辑相关的错误码。公共错误码请参见公共错误码文档。​
​
状态码​
错误码​
错误信息​
说明​
400​
AuditLogDisabled​
Audit logging is disabled for the specified cluster.​
指定集群未开启审计日志。​
400​
AuditLogInvalidParameter​
The audit log request is invalid: %s​
审计日志请求参数无效:%s​
400​
DefaultPrivateEndpointCannotBeDeleted​
The default private endpoint %s cannot be deleted from the allowlist.​
默认私网终端节点 %s 不能从白名单中删除。​
400​
DefaultPrivateEndpointCannotBeReplaced​
The default private endpoint %s cannot be replaced. Only its allowlist rule name can be changed.​
默认私网终端节点 %s 不支持替换,只能修改其白名单规则名称。​
400​
PrivateEndpointServiceMismatch​
The specified private endpoint %s is not connected to the TiDB endpoint service for this cluster.​
私网终端节点 %s 未连接到当前集群对应的 TiDB 终端节点服务。​
400​
InvalidPrivateEndpoint​
The specified private endpoint %s is invalid: %s.​
私网终端节点 %s 无效:%s。​
400​
DisplayNameNotUnique​
Cluster names must be unique. The current name [%s] already exists. Please use a different name.​
集群名称需保持唯一,当前名称%s已存在,请使用其他名称。​
400​
QuotaExceeded​
The account quota has been exceeded.​
账号配额已超限。​
400​
OperationUnsupported​
The operation is unsupported for the specified cluster. %s​
操作不支持。%s​
400​
InvalidParameterFormat​
The input parameter is not valid.​
请求参数格式错误。​
400​
UnsupportedParameter​
The specified parameter %s is not support.​
当前参数%s值不支持。​
400​
InvalidParameter​
The specified parameter %s is not valid.​
参数%s值无效。​
400​
MissingParameter​
The input parameter %s that is mandatory for processing this request is not supplied.​
缺少%s参数。​
400​
MissingParameter​
The input parameter %s that is mandatory for processing this request is not supplied.​
缺少%s参数。​
400​
InvalidParameter​
The specified parameter %s is not valid.​
参数%s值无效。​
400​
UnsupportedParameter​
The specified parameter %s is not support.​
当前参数%s值不支持。​
400​
InvalidParameterFormat​
The input parameter is not valid.​
请求参数格式错误。​
400​
OperationUnsupported​
The operation is unsupported for the specified cluster. %s​
操作不支持。%s​
400​
QuotaExceeded​
The account quota has been exceeded.​
账号配额已超限。​
400​
DisplayNameNotUnique​
Cluster names must be unique. The current name [%s] already exists. Please use a different name.​
集群名称需保持唯一,当前名称%s已存在,请使用其他名称。​
400​
InvalidPrivateEndpoint​
The specified private endpoint %s is invalid: %s.​
私网终端节点 %s 无效:%s。​
400​
PrivateEndpointServiceMismatch​
The specified private endpoint %s is not connected to the TiDB endpoint service for this cluster.​
私网终端节点 %s 未连接到当前集群对应的 TiDB 终端节点服务。​
400​
DefaultPrivateEndpointCannotBeReplaced​
The default private endpoint %s cannot be replaced. Only its allowlist rule name can be changed.​
默认私网终端节点 %s 不支持替换,只能修改其白名单规则名称。​
400​
DefaultPrivateEndpointCannotBeDeleted​
The default private endpoint %s cannot be deleted from the allowlist.​
默认私网终端节点 %s 不能从白名单中删除。​
400​
AuditLogInvalidParameter​
The audit log request is invalid: %s​
审计日志请求参数无效:%s​
400​
AuditLogDisabled​
Audit logging is disabled for the specified cluster.​
指定集群未开启审计日志。​
403​
PermissionDenied​
You are not authorized to perform this operation.​
没有权限执行该操作。​
403​
PermissionDenied​
You are not authorized to perform this operation.​
没有权限执行该操作。​
404​
PrivateEndpointNotFound​
The specified private endpoint %s does not exist.​
未找到私网终端节点 %s。​
404​
AuditLogFilterRuleNotFound​
The specified audit log filter rule %s does not exist.​
未找到审计日志过滤规则 %s。​
404​
RestoreJobNotFound​
No restore job found for the specified cluster.​
未找到恢复任务。​
404​
TableNotFound​
The specified table %s does not exist.​
未找到Table %s​
404​
PrivateEndpointAllowlistRuleNotFound​
The private endpoint allowlist rule for VpcEndpointId %s does not exist.​
未找到 VpcEndpointId 为 %s 的私网白名单规则。​
404​
BranchNotFound​
The specified branch %s does not exist.​
未找到BranchId %s。​
404​
ClusterNotFound​
The specified cluster %s does not exist.​
未找到ClusterId %s。​
404​
ProjectNotFound​
The specified project %s does not exist.​
未找到Project %s。​
404​
ProjectNotFound​
The specified project %s does not exist.​
未找到Project %s。​
404​
ClusterNotFound​
The specified cluster %s does not exist.​
未找到ClusterId %s。​
404​
BranchNotFound​
The specified branch %s does not exist.​
未找到BranchId %s。​
404​
PrivateEndpointNotFound​
The specified private endpoint %s does not exist.​
未找到私网终端节点 %s。​
404​
PrivateEndpointAllowlistRuleNotFound​
The private endpoint allowlist rule for VpcEndpointId %s does not exist.​
未找到 VpcEndpointId 为 %s 的私网白名单规则。​
404​
TableNotFound​
The specified table %s does not exist.​
未找到Table %s​
404​
RestoreJobNotFound​
No restore job found for the specified cluster.​
未找到恢复任务。​
404​
AuditLogFilterRuleNotFound​
The specified audit log filter rule %s does not exist.​
未找到审计日志过滤规则 %s。​
409​
AuditLogFilterRuleAlreadyExists​
The audit log filter rule %s already exists.​
审计日志过滤规则 %s 已存在。​
409​
PrivateEndpointNotAvailable​
The specified private endpoint %s is not available. Current status: %s.​
私网终端节点 %s 当前不可用,当前状态:%s。​
409​
PrivateEndpointAllowlistRuleAlreadyExists​
The private endpoint allowlist rule for VpcEndpointId %s already exists.​
VpcEndpointId 为 %s 的私网白名单规则已存在。​
409​
PrivateEndpointAllowlistRuleAlreadyExists​
The private endpoint allowlist rule for VpcEndpointId %s already exists.​
VpcEndpointId 为 %s 的私网白名单规则已存在。​
409​
PrivateEndpointNotAvailable​
The specified private endpoint %s is not available. Current status: %s.​
私网终端节点 %s 当前不可用,当前状态:%s。​
409​
AuditLogFilterRuleAlreadyExists​
The audit log filter rule %s already exists.​
审计日志过滤规则 %s 已存在。​
500​
InternalError​
The request processing has failed due to some unknown error, exception or failure.​
内部错误。​
500​
ServiceBusy​
The system is busy, please try again later.​
系统繁忙,请稍后重试。​
500​
TiDBError​
err from tidb: %s​
TiDB错误:%s。​
500​
InternalError​
The request processing has failed due to some unknown error, exception or failure.​
内部错误。​
500​
TiDBError​
err from tidb: %s​
TiDB错误:%s​
500​
ServiceBusy​
The system is busy, please try again later.​
系统繁忙,请稍后重试。​
503​
ServiceUnavailable​
The request has failed due to a temporary failure of the server.​
当前服务暂时不可用。​
503​
ServiceUnavailable​
The request has failed due to a temporary failure of the server.​
当前服务暂时不可用。​
​
​
最近更新时间:2026.10.30 11:06:01
这个页面对您有帮助吗?
有用
有用
无用
无用