使用 Terraform 和 OCI 资源管理器更新 Oracle NoSQL 表

在本文中,我们将了解使用 Terraform 更新现有 NDCS 表方案或存储(读取或写入)单元的步骤。我们将使用 OCI 资源管理器 CLI 更新 NDCS 表。在我们继续本文之前,假定您已了解 NoSQL Cloud Service 并知道其基础知识以及 Terraform。

第一步是使用必要的配置更改创建覆盖文件。然后运行资源管理器 CLI 命令以执行以下任务:
  • 更新堆栈。
  • 生成和复核执行计划。
  • 运行 "Apply"(应用)作业以更新所需的 NoSQL 资源。
  • 根据需要复核日志文件。

本文章包含以下主题:

Prerequisites

  • 具有 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 配置 zip 文件 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 配置文件的新更新 zip 文件更新了现有堆栈。

步骤 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"
}
您可以检查应用作业的状态,以验证作业是“成功”还是“失败”。
{
...
      "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 数据库表的方案所需的覆盖 terraform 配置文件,然后使用 OCI 资源管理器 CLI 更新现有堆栈,生成执行计划,并在执行计划上运行应用作业。