使用 Terraform 和 OCI 資源管理程式更新 Oracle NoSQL 表格

在本文中,我們將看到使用 Terraform 更新現有 NDCS 表格結構描述或儲存 (讀取或寫入) 單位的步驟。我們將使用 OCI 資源管理程式 CLI 更新 NDCS 表格。在繼續本文之前,假設您瞭解 NoSQL Cloud Service 並瞭解其基本知識以及 Terraform。

第一步是建立具有必要組態變更的覆寫檔案。然後執行「資源管理程式 CLI」命令,執行下列作業:
  • 更新堆疊。
  • 產生並複查執行計畫。
  • 執行「套用」工作以更新必要的 NoSQL 資源。
  • 視需要檢視日誌檔。

本文包含下列主題:

必備條件

  • 含有 NoSQL 資料庫資源 (例如表格或索引) 的現有堆疊。
  • 用於建立 NoSQL 資料庫資源 (例如表格或索引) 的現有 Terraform 組態檔。

步驟 1:建立 NoSQL 資料庫表格的 Terraform 覆寫檔案

建立一個名為 "nosql_override.tf " 或 "override.tf " 的新檔案,並提供要覆寫之 NoSQL 資料庫表格物件的特定部分。例如,您可能想要從表格新增或刪除資料欄,變更現有資料欄的資料類型,或變更表格限制 (讀取 / 寫入和儲存體單位)。

在下面的範例中,我們將修改 demo 表格以刪除名為 fullName 的現有資料欄,並修改 demoKeyVal 表格以在結尾新增名為 shortName 的新資料欄。

舉例而言:

如果您的 Terraform 組態為 nosql.tf,且包含下列內容:
variable "compartment_ocid" {
}
resource "oci_nosql_table" "nosql_demo" {
    compartment_id = var.compartment_ocid
    ddl_statement = "CREATE TABLE if not exists demo (ticketNo INTEGER, fullName STRING, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY (ticketNo))"
    name = "demo"
    table_limits {
        max_read_units = var.table_table_limits_max_read_units
        max_storage_in_gbs = var.table_table_limits_max_storage_in_gbs
        max_write_units = var.table_table_limits_max_write_units
    }
}
resource "oci_nosql_table" "nosql_demoKeyVal" {
    compartment_id = var.compartment_ocid
    ddl_statement = "CREATE TABLE if not exists demoKeyVal (key INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1 NO CYCLE), value JSON, PRIMARY KEY (key))"
    name = "demoKeyVal"
    table_limits {
       max_read_units = var.table_table_limits_max_read_units
        max_storage_in_gbs = var.table_table_limits_max_storage_in_gbs
        max_write_units = var.table_table_limits_max_write_units
    }
}
您現在想要修改 demo 表格並刪除名為 fullName 的現有資料欄,然後修改 demoKeyVal 表格,在結尾新增名為 shortName 的新資料欄。然後建立包含下列內容的檔案 nosql_override.tfoverride.tf
variable "compartment_ocid" {
}
resource "oci_nosql_table" "nosql_demo" {
    compartment_id = var.compartment_ocid
    ddl_statement = "CREATE TABLE if not exists demo (ticketNo INTEGER, contactPhone STRING,
    confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY (ticketNo))"
    name = "demo"   
}
resource "oci_nosql_table" "nosql_demoKeyVal" {
    compartment_id = var.compartment_ocid
    ddl_statement = "CREATE TABLE if not exists demoKeyVal (key INTEGER GENERATED ALWAYS AS IDENTITY 
    (START WITH 1 INCREMENT BY 1 NO CYCLE), value JSON, shortName STRING, PRIMARY KEY (key))"
    name = "demoKeyVal"  
}

附註:

新增資料欄至現有表格時,您只能在表格結尾附加資料欄。您無法在任何現有資料欄之前插入新資料欄,或變更現有資料欄的順序。例如,您無法在 value 資料欄之前新增 shortName 資料欄,或交換 demoKeyVal 表格中的 keyvalue 資料欄。這會導致錯誤。

當 Terraform 在內部處理此檔案 (nosql_override.tf) 時,它會剖析 DDL 敘述句 (CREATE TABLE 敘述句),並將它與現有的表格定義做比較,並產生等效的 ALTER TABLE 敘述句並加以套用。

步驟 2:更新執行計畫

附註:

這些指示不適用於儲存在原始程式碼控制系統中的組態。如果您使用原始程式碼控制系統 (例如 GitHub 和 Gitlab) 來維護 terraform 組態檔,可以略過此步驟並直接移至步驟 3。在關聯堆疊上執行的任何工作都會自動使用最新版本的組態。
在本教學課程中,我們將使用更新的 terraform 組態壓縮檔 terraform.zip 檔案來更新執行計畫。更新的 terraform.zip 檔案包含下列檔案:
  • provider.tf
  • nosql.tf
  • nosql_override.tf or override.tf
  • terraform.tfvars
  • variables.tf
舉例而言:
oci resource-manager stack update 
--stack-id ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq 
--config-source terraform.zip
範例回應:
{
  "data": {
    "compartment-id": "ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya",
    "config-source": {
      "config-source-type": "ZIP_UPLOAD",
      "working-directory": null
    },
    "defined-tags": {},
    "description": null,
    "display-name": "ormstack20220117104810",
    "freeform-tags": {},
    "id": "ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq", 
    "lifecycle-state": "ACTIVE",
    "stack-drift-status": "NOT_CHECKED",
    "terraform-version": "1.0.x",
    "time-created": "2022-01-17T10:48:10.878000+00:00",
    "time-drift-last-checked": null,
    "variables": {}
  },
  "etag": "068e7b962aa43c7b3e7bf5c24b2d7f937db0901a784a9dce8715d76d78ad30f3"
}

我們已使用包含覆寫 terraform 組態檔的新更新壓縮檔更新現有堆疊。

步驟 3:產生執行計畫

如果要產生執行計畫,請執行下列命令:
oci resource-manager job create-plan-job 
–-stack-id <stack_OCID> 
--display-name "<friendly_name>"
舉例而言:
oci resource-manager job create-plan-job 
--stack-id ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq
範例回應:
{
  "data": {
    "apply-job-plan-resolution": null,
    "cancellation-details": {
      "is-forced": false
    },
    "compartment-id": "ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya",
    "config-source": {
      "config-source-record-type": "ZIP_UPLOAD"
    },
    "defined-tags": {},
    "display-name": "ormjob20220124122310",
    "failure-details": null,
    "freeform-tags": {},
    "id": "ocid1.ormjob.oc1.phx.aaaaaaaagke5ajwwchvxkql2c56qoohhvc2dxu5fnqswnpw4hsombrfijnia",
    "job-operation-details": {
      "operation": "PLAN",
      "terraform-advanced-options": {
        "detailed-log-level": null,
        "is-refresh-required": true,
        "parallelism": 10
      }
    },
    "lifecycle-state": "ACCEPTED",
    "operation": "PLAN",
    "resolved-plan-job-id": null,
    "stack-id": "ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq",
    "time-created": "2022-01-24T12:23:10.366000+00:00",
    "time-finished": null,
    "variables": {},
    "working-directory": null
  },
  "etag": "b77d497287af3dd2d166871457d880ffee9952ee2c9a44e8f9dfa3e02b974c95"
}
我們已從堆疊產生執行計畫。「資源管理程式」會使用與此執行計畫對應的唯一 ID 來建立工作。此計畫工作 ID 之後可用來複查執行計畫詳細資訊,再執行套用作業在 OCI 雲端部署 NoSQL 資料庫資源。
"id": "ocid1.ormjob.oc1.phx.aaaaaaaagke5ajwwchvxkql2c56qoohhvc2dxu5fnqswnpw4hsombrfijnia",
"job-operation-details": {
      "operation": "PLAN"
      ...
}

子步驟 3.1:複查執行計畫

如果要複查執行計畫,請執行下列命令:
oci resource-manager job get-job-logs 
--job-id <plan_job_OCID>
舉例而言:
oci resource-manager job get-job-logs 
--job-id ocid1.ormjob.oc1.phx.aaaaaaaagke5ajwwchvxkql2c56qoohhvc2dxu5fnqswnpw4hsombrfijnia
範例回應:
...
    {
      "level": "INFO",
      "message": "  # data.oci_nosql_table.nosql_demo will be read during apply",
      "timestamp": "2022-01-24T12:23:36.445000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": " <= data \"oci_nosql_table\" \"nosql_demo\"  {",
      "timestamp": "2022-01-24T12:23:36.445000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ ddl_statement       = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY(SHARD(ticketNo)))\" -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.445000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ id                  = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a\" -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.445000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ is_auto_reclaimable = true -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.445000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "          - \"orcl-cloud.free-tier-retained\" = \"true\"",
      "timestamp": "2022-01-24T12:23:36.446000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  # data.oci_nosql_table.nosql_demoKeyVal will be read during apply",
      "timestamp": "2022-01-24T12:23:36.446000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": " <= data \"oci_nosql_table\" \"nosql_demoKeyVal\"  {",
      "timestamp": "2022-01-24T12:23:36.446000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ ddl_statement       = \"CREATE TABLE IF NOT EXISTS demoKeyVal(key INTEGER, value JSON, shortName STRING, PRIMARY KEY(SHARD(key)))\" -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.446000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ id                  = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq\" -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ is_auto_reclaimable = true -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  # oci_nosql_table.nosql_demo will be updated in-place",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ resource \"oci_nosql_table\" \"nosql_demo\" {",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ ddl_statement       = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, fullName STRING, PRIMARY KEY(SHARD(ticketNo)))\" -> \"ALTER TABLE demo (DROP fullName)\"",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  # oci_nosql_table.nosql_demoKeyVal will be updated in-place",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ resource \"oci_nosql_table\" \"nosql_demoKeyVal\" {",
      "timestamp": "2022-01-24T12:23:36.447000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ ddl_statement       = \"CREATE TABLE IF NOT EXISTS demoKeyVal(key INTEGER, value JSON, PRIMARY KEY(SHARD(key)))\" -> \"ALTER TABLE demoKeyVal (ADD shortName STRING)\"",
      "timestamp": "2022-01-24T12:23:36.448000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ nosql_kv_table_ddl_statement = \"CREATE TABLE IF NOT EXISTS demoKeyVal(key INTEGER, value JSON, shortName STRING, PRIMARY KEY(SHARD(key)))\" -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.448000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ nosql_table_ddl_statement    = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY(SHARD(ticketNo)))\" -> (known after apply)",
      "timestamp": "2022-01-24T12:23:36.448000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
...
此步驟非常重要,因為它驗證更新的堆疊程式碼是否包含任何語法錯誤,以及新增、更新或銷毀的 OCI 資源數目。在教學課程中,我們透過新增和刪除資料欄來更新兩個 NoSQL 表格的綱要:demodemoKeyVal
{
 ...
      "message": "Plan: 0 to add, 2 to change, 0 to destroy.",
 ...
}

步驟 4:執行套用工作

  • 若要指定計畫工作 (套用執行計畫),請使用 FROM_PLAN_JOB_ID
    oci resource-manager job create-apply-job 
    --stack-id <stack_OCID> 
    --execution-plan-strategy FROM_PLAN_JOB_ID 
    --execution-plan-job-id <plan_job_OCID> 
    --display-name "Example Apply Job"
  • 若要自動核准套用工作 (未指定計畫工作),請使用 AUTO_APPROVED
    oci resource-manager job create-apply-job 
    --stack-id <stack_OCID> 
    --execution-plan-strategy AUTO_APPROVED 
    --display-name "Example Apply Job"
舉例而言:
oci resource-manager job create-apply-job 
--stack-id ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq 
--execution-plan-strategy AUTO_APPROVED 
--display-name "Update NoSQL Tables Using Terraform"
範例回應:
{
  "data": {
    "apply-job-plan-resolution": {
      "is-auto-approved": true,
      "is-use-latest-job-id": null,
      "plan-job-id": null
    },
    "cancellation-details": {
      "is-forced": false
    },
    "compartment-id": "ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya",
    "config-source": {
      "config-source-record-type": "ZIP_UPLOAD"
    },
    "defined-tags": {},
    "display-name": "Update NoSQL Tables Using Terraform",
    "failure-details": null,
    "freeform-tags": {},
    "id": "ocid1.ormjob.oc1.phx.aaaaaaaacmnanu2qd34x7l5uicgpdfpjbsgh5swddmtslb3qmbzg3dmuc3bq",
    "job-operation-details": {
      "execution-plan-job-id": null,
      "execution-plan-strategy": "AUTO_APPROVED",
      "operation": "APPLY",
      "terraform-advanced-options": {
        "detailed-log-level": null,
        "is-refresh-required": true,
        "parallelism": 10
      }
    },
    "lifecycle-state": "ACCEPTED",
    "operation": "APPLY",
    "resolved-plan-job-id": null,
    "stack-id": "ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq",
    "time-created": "2022-01-24T12:36:52.911000+00:00",
    "time-finished": null,
    "variables": {},
    "working-directory": null
  },
  "etag": "b2af026af48897c7839c347e06a8c40ec3ce1cac08a3da2f0c6ee74fb07078ab"
}

子步驟 4.1:驗證工作狀態

若要驗證工作的狀態,請執行下列命令:
oci resource-manager job get 
--job-id <job_OCID>
舉例而言:
oci resource-manager job get 
--job-id ocid1.ormjob.oc1.phx.aaaaaaaacmnanu2qd34x7l5uicgpdfpjbsgh5swddmtslb3qmbzg3dmuc3bq
範例回應:
{
  "data": {
    "apply-job-plan-resolution": {
      "is-auto-approved": true,
      "is-use-latest-job-id": null,
      "plan-job-id": null
    },
    "cancellation-details": {
      "is-forced": false
    },
    "compartment-id": "ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya",
    "config-source": {
      "config-source-record-type": "ZIP_UPLOAD"
    },
    "defined-tags": {},
    "display-name": "ALTER NoSQL Table Schema",
    "failure-details": null,
    "freeform-tags": {},
    "id": "ocid1.ormjob.oc1.phx.aaaaaaaacmnanu2qd34x7l5uicgpdfpjbsgh5swddmtslb3qmbzg3dmuc3bq",
    "job-operation-details": {
      "execution-plan-job-id": null,
      "execution-plan-strategy": "AUTO_APPROVED",
      "operation": "APPLY",
      "terraform-advanced-options": {
        "detailed-log-level": null,
        "is-refresh-required": true,
        "parallelism": 10
      }
    },
    "lifecycle-state": "SUCCEEDED",
    "operation": "APPLY",
    "resolved-plan-job-id": null,
    "stack-id": "ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq",
    "time-created": "2022-01-20T11:14:13.916000+00:00",
    "time-finished": "2022-01-20T11:14:51.921000+00:00",
    "variables": {},
    "working-directory": null
  },
  "etag": "13b1253bd5e6ca78778b4cf6aad38d262b1476aae06e6f36b40b5f914016b899--gzip"
}
您可以檢查套用工作的狀態,以驗證工作是否為 SUCCESSFUL 或 FAILED。
{
...
      "lifecycle-state": "SUCCEEDED",
...
}

子步驟 4.2:檢視工作的日誌

若要檢視工作的記錄,請執行下列指令:
oci resource-manager job get-job-logs-content 
--job-id <job_OCID>
舉例而言:
oci resource-manager job get-job-logs-content
--job-id ocid1.ormjob.oc1.phx.aaaaaaaacmnanu2qd34x7l5uicgpdfpjbsgh5swddmtslb3qmbzg3dmuc3bq
範例回應:
...
    {
      "level": "INFO",
      "message": "oci_nosql_table.nosql_demoKeyVal: Refreshing state... [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq]",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "oci_nosql_table.nosql_demo: Refreshing state... [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a]",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "plan. Resource actions are indicated with the following symbols:",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ update in-place",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "Terraform will perform the following actions:",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  # data.oci_nosql_table.nosql_demo will be read during apply",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": " <= data \"oci_nosql_table\" \"nosql_demo\"  {",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      + compartment_id      = \"ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      + table_name_or_id    = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": " <= data \"oci_nosql_table\" \"nosql_demoKeyVal\"  {",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      + compartment_id      = \"ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      + table_name_or_id    = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  # oci_nosql_table.nosql_demo will be updated in-place",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ resource \"oci_nosql_table\" \"nosql_demo\" {",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ ddl_statement       = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, fullName STRING, PRIMARY KEY(SHARD(ticketNo)))\" -> \"ALTER TABLE demo (DROP fullName)\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "        id                  = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "        name                = \"demo\"",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  # oci_nosql_table.nosql_demoKeyVal will be updated in-place",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "  ~ resource \"oci_nosql_table\" \"nosql_demoKeyVal\" {",
      "timestamp": "2022-01-20T11:14:26.632000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "      ~ ddl_statement       = \"CREATE TABLE if not exists demoKeyVal (key INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1 NO CYCLE), value JSON, PRIMARY KEY (key))\" -> \"ALTER TABLE demoKeyVal (ADD shortName STRING)\"",
      "timestamp": "2022-01-20T11:14:26.633000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "        id                  = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq\"",
      "timestamp": "2022-01-20T11:14:26.633000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "        name                = \"demoKeyVal\"",
      "timestamp": "2022-01-20T11:14:26.633000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "Plan: 0 to add, 2 to change, 0 to destroy.",
      "timestamp": "2022-01-20T11:14:26.633000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "oci_nosql_table.nosql_demoKeyVal: Modifying... [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq]",
      "timestamp": "2022-01-20T11:14:27.633000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "oci_nosql_table.nosql_demo: Modifying... [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a]",
      "timestamp": "2022-01-20T11:14:27.633000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "oci_nosql_table.nosql_demo: Modifications complete after 9s [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a]",
      "timestamp": "2022-01-20T11:14:35.634000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "data.oci_nosql_table.nosql_demo: Reading...",
      "timestamp": "2022-01-20T11:14:35.634000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "data.oci_nosql_table.nosql_demo: Read complete after 0s [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a]",
      "timestamp": "2022-01-20T11:14:35.634000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "data.oci_nosql_table.nosql_demoKeyVal: Reading...",
      "timestamp": "2022-01-20T11:14:44.636000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "data.oci_nosql_table.nosql_demoKeyVal: Read complete after 0s [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq]",
      "timestamp": "2022-01-20T11:14:44.636000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "Apply complete! Resources: 0 added, 2 changed, 0 destroyed.",
      "timestamp": "2022-01-20T11:14:44.636000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "nosql_kv_table_ddl_statement = \"CREATE TABLE IF NOT EXISTS demoKeyVal(key INTEGER, value JSON, shortName STRING, PRIMARY KEY(SHARD(key)))\"",
      "timestamp": "2022-01-20T11:14:44.636000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
    {
      "level": "INFO",
      "message": "nosql_table_ddl_statement = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY(SHARD(ticketNo)))\"",
      "timestamp": "2022-01-20T11:14:44.636000+00:00",
      "type": "TERRAFORM_CONSOLE"
    },
... 
此步驟非常重要,因為它確認新增、更新或銷毀了多少 OCI 資源。在教學課程中,我們已成功更新兩個 NoSQL 表格的綱要:demodemoKeyVal
{
 ...
      "message": "Apply complete! Resources: 0 added, 2 changed, 0 destroyed.",
 ...
}

本教學課程提供許多詳細資訊。我們建立了覆寫更新 OCI 雲端上 NoSQL 資料庫表格綱要所需的地形組態檔,然後使用 OCI 資源管理程式 CLI 更新現有的堆疊、產生執行計畫,以及在執行計畫上執行套用工作。