Database change management

2024-05-17 03:14:05  Updated

Background information

OceanBase Developer Center (ODC) allows you to change the data in your database. You can create a database change task to run time-consuming SQL statements to avoid an execution timeout.

Considerations

  • A rollback statement can be automatically generated only for the UPDATE and DELETE statements.

  • A change task is allowed to affect a maximum of 1 million rows. If the number of affected rows exceeds 1 million, a rollback statement cannot be automatically generated for this change task.

  • If the table contains LOB fields, a rollback statement cannot be automatically generated.

  • If the table does not have a primary or unique key when the data source is an OceanBase MySQL or a MySQL data source, a rollback statement cannot be automatically generated.

  • If the SET and WHERE clauses in an UPDATE statement are the same, a rollback statement cannot be automatically generated.

  • The maximum size of a rollback script that is automatically generated is 256 MB.

Create a database change task

Example: Change the value of name in the employee table in the odc_test database from xiaoguo to xiaofeng.

Parameter Example value
Project name odc_4.2.0
Data source mysql410
Database name odc_test
Table name employee
  1. Choose Projects > All Projects. On the tab that appears, click the project name odc_4.2.0.

    1

  2. On the Ticket tab, choose Database Change > Create Database Change Task.

    2

  3. In the Create Database Change Task panel, configure the following parameters.

    3

    Parameter Description
    Database Select the database to which the database change task belongs.
    SQL Content Select SQL Entry or Upload File.
    • SQL Entry: This is the default way to specify SQL content. You can directly write the SQL script in the editing area.

      Note

      • The maximum size of the SQL statements that can be entered in the SQL window is limited to 500,000 characters. If the SQL script to be executed has more than 500,000 characters, you can directly upload the script file.
      • You can click IN Value Conversion to convert the batch copied data into the in('A','B') format.
      • Column values are separated with line breaks.
      • Row values are separated with spaces or tabs.
    • Upload File: Click the file pool to go to the file explorer and select the file to be imported. You can also directly drag the file to the file pool to upload it.

      Note

      • You can upload up to 500 files. The total file size cannot exceed 256 MB.
      • By default, files are sorted by the order in which they were uploaded. You can drag and drop them to change the order. Tasks are executed in the file order.
      • Only SQL files suffixed with .sql are supported.
    SQL Check Click this icon to check the syntax of the SQL statement.
    Rollback Plan Specify Rollback Plan. You can write an SQL script or upload a file to specify the rollback plan. For more information, see the description of SQL Content.

    Note

    You can select Generate Backup Rollback Plan so that backup rollback SQL statements will be automatically generated for UPDATE and DELETE statements.

    • For OceanBase Database in MySQL mode or MySQL Database, a rollback SQL statement can be generated only for an UPDATE or DELETE statement executed on a table with a primary or unique key.
    • A backup rollback SQL statement can be generated only when a database change statement affects no more than 100,000 rows and the database change task affects no more than 1 million rows.
    Delimiter Delimiters are supported.
    Query Result Limit You can set the maximum number of rows allowed in the query result. Value range: 1 to 1000000.
    Task Settings
    • The database change tool provides two error handling methods:
      • Abort Task: This is the default option. When you select this option, the task is aborted if an error occurs when you run the script.
      • Ignore Error and Continue: When you select this option, the system skips the erroneous statement where an error occurs and continues to execute other statements in the script.
    • Select Execute Now or Scheduled Execution.
    Execution Timeout Value Specify the value in the Execution Timeout Value field in hours. Default value: 48. Maximum value: 480.
    Description You can enter a description of no more than 200 characters in Task Description. This field is optional.
  4. Click Create. The database change task is created.

  5. On the Ticket tab, view the task information in the database change task list.

    4

View a database change task

Task information

  1. In the database change task list on the Ticket tab shown in the preceding figure, click View in the Actions column of the target task.

  2. In the Task Details panel, click the Task Information tab to view the database, type, risk level, SQL content, and rollback statement of the task.

    Note

    You can click Download Backup Rollback Plan to download the rollback plan file automatically generated by ODC for UPDATE and DELETE statements.

    5

  3. Click Initiate Again to initiate the database change task again, or click Roll Back to roll back the task.

Task process

6

In the Task Details panel, click the Task Process tab and view information such as the task initiation status, approval status, execution status, and execution result.

Execution result

7

In the Task Details panel, click the Execution Result tab to view the execution success and failure records.

Rollback ticket

In the Task Details panel, click Rollback Ticket to view the rollback task.

Task logs

8

In the Task Details panel, click the Task Logs tab to view all logs and alert logs of the task.

Tab Description
All Logs Displays the complete information of all task logs, including INFO, ERROR, and WARN logs. You can click Search, Download, or Copy to search for, download, or copy all logs.
Alert Logs Displays the ERROR and WARN logs of the task. When a task fails, you can view the error message in the alert logs. You can click Search, Download, or Copy to search for, download, or copy alert logs.

References

Contact Us