取消資料匯入和匯出作業
  
      
    
  
  
  
  
  
    
  
  
    
    
    
    
  
  
本頁說明如何取消將資料匯入 Cloud SQL 執行個體,以及從 Cloud SQL 執行個體匯出資料。這些資料會儲存在 SQL 傾印檔案或 BAK 檔案中。
事前準備
取消匯入或匯出作業
您可以使用 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 API 呼叫不會傳回任何回應。如要進一步瞭解如何檢查匯入或匯出作業的取消狀態,請參閱「檢查取消狀態」。
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 回應:
    
這個 REST API 呼叫不會傳回任何回應。如要進一步瞭解如何檢查匯入或匯出作業的取消狀態,請參閱「檢查取消狀態」。
 
查看取消狀態
您可以使用 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": "user@example.com",
  "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": "user@example.com",
  "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-10-19 (世界標準時間)。
  
  
    
    
    
      
  
    
  
  
    
      [[["容易理解","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-10-19 (世界標準時間)。"],[],[]]