取消資料匯入和匯出作業
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
MySQL
| PostgreSQL
| SQL Server
本頁面說明如何取消將資料匯入及匯出至 Cloud SQL 執行個體。這項資料包含在 SQL 傾印檔案或 CSV 檔案中。
事前準備
取消匯入或匯出作業
您可以使用 gcloud
或 REST API 指令取消匯入或匯出作業。
gcloud
使用 gcloud sql operations cancel
指令取消作業。
gcloud sql operations cancel operation-ID
將 operation-ID 變數替換為作業 ID。詳情請參閱「事前準備」一節。
REST v1
使用任何要求資料之前,請先替換以下項目:
- project-ID:專案 ID。
- operation-ID:匯入或匯出作業的 ID。詳情請參閱「事前準備」一節。
HTTP 方法和網址:
POST https://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID/cancel
如要傳送要求,請展開以下其中一個選項:
curl (Linux、macOS 或 Cloud Shell)
執行下列指令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID/cancel"
PowerShell (Windows)
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID/cancel" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
如要進一步瞭解如何檢查匯入或匯出作業的取消狀態,請參閱「檢查已取消的狀態」。
REST v1beta4
使用任何要求資料之前,請先替換以下項目:
- project-ID:專案 ID。
- operation-ID:匯入或匯出作業的 ID。詳情請參閱「事前準備」一節。
HTTP 方法和網址:
POST https://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID/cancel
如要傳送要求,請展開以下其中一個選項:
curl (Linux、macOS 或 Cloud Shell)
執行下列指令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID/cancel"
PowerShell (Windows)
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID/cancel" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
如要進一步瞭解如何檢查匯入或匯出作業的取消狀態,請參閱「檢查已取消的狀態」。
查看已取消的狀態
您可以使用 gcloud
或 REST API 指令,查看已取消的匯入或匯出作業狀態。
REST v1
使用任何要求資料之前,請先替換以下項目:
- project-ID:專案 ID。
- operation-ID:匯入或匯出作業的 ID。詳情請參閱「事前準備」一節。
HTTP 方法和網址:
GET https://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID
如要傳送要求,請展開以下其中一個選項:
curl (Linux、macOS 或 Cloud Shell)
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID"
PowerShell (Windows)
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
回應
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/v1/projects/project-ID",
"status": "DONE",
"user": "[email protected]",
"insertTime": "2022-11-08T22:12:58.199Z",
"startTime": "2022-11-08T22:13:04.798Z",
"endTime": "2022-11-08T22:13:45.862Z",
"error": {
"kind": "sql#operationErrors",
"errors": [
{
"kind": "sql#operationError",
"code": "CANCEL_SUCCESSFUL",
"message": "Operation successfully cancelled"
}
]
},
"operationType": "EXPORT",
"exportContext": {
"uri": "gs://replica-bucket/source-database.sql",
"kind": "sql#exportContext",
"sqlExportOptions": {
"schemaOnly": false,
"mysqlExportOptions": {
"masterData": 0
}
},
"fileType": "SQL"
},
"name": "operation-ID",
"targetId": "cloud-sql-instance-display-name",
"selfLink": "https://sqladmin.googleapis.com/v1/projects/project-ID/operations/operation-ID",
"targetProject": "project-ID",
"instanceUid": "cloud-sql-instance-ID"
}
REST v1beta4
使用任何要求資料之前,請先替換以下項目:
- project-ID:專案 ID。
- operation-ID:匯入或匯出作業的 ID。詳情請參閱「事前準備」一節。
HTTP 方法和網址:
GET https://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID
如要傳送要求,請展開以下其中一個選項:
curl (Linux、macOS 或 Cloud Shell)
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID"
PowerShell (Windows)
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
回應
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/v1beta4/projects/project-ID",
"status": "DONE",
"user": "[email protected]",
"insertTime": "2022-11-08T22:12:58.199Z",
"startTime": "2022-11-08T22:13:04.798Z",
"endTime": "2022-11-08T22:13:45.862Z",
"error": {
"kind": "sql#operationErrors",
"errors": [
{
"kind": "sql#operationError",
"code": "CANCEL_SUCCESSFUL",
"message": "Operation successfully cancelled"
}
]
},
"operationType": "EXPORT",
"exportContext": {
"uri": "gs://replica-bucket/source-database.sql",
"kind": "sql#exportContext",
"sqlExportOptions": {
"schemaOnly": false,
"mysqlExportOptions": {
"masterData": 0
}
},
"fileType": "SQL"
},
"name": "operation-ID",
"targetId": "cloud-sql-instance-display-name",
"selfLink": "https://sqladmin.googleapis.com/v1beta4/projects/project-ID/operations/operation-ID",
"targetProject": "project-ID",
"instanceUid": "cloud-sql-instance-ID"
}
疑難排解
問題 |
疑難排解 |
錯誤訊息:You can't cancel operation [operation-ID] because
this operation isn't in progress. |
您嘗試取消已完成、失敗或已取消的匯入或匯出作業。如果作業正在執行,您可以取消作業。
|
錯誤訊息:You can't cancel operation [operation-ID] because
Cloud SQL doesn't support the cancellation of an [operation-type]
operation. |
Cloud SQL 不支援作業的取消作業,因為它具有 IMPORT 或 EXPORT 以外的作業類型。
|
錯誤訊息:The [operation-type] operation isn't cancelled. Wait
and retry in a few seconds. |
Cloud SQL 目前無法取消匯入或匯出作業。
請稍後再試。如果問題仍未解決,請與Google Cloud 支援團隊聯絡。
|
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-05-16 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-05-16 (世界標準時間)。"],[],[]]