This topic describes how to create and manage SQL plan tasks in ODC.
Background information
OceanBase Developer Center (ODC) can periodically execute SQL scripts created by users to complete database development and O&M tasks as required by the users. For example, ODC can periodically execute stored procedures, backup, and database and table schema synchronization.
After a user creates an SQL plan task in
Create an SQL plan task
Assume that you want to create a task to query the employee table on the 2nd and 29th of each month.
| Parameter | Example value |
|---|---|
| Data Source | mysql_4.2.0 |
| Database Name | odc_test |
| Table Name | employee |
In the SQL development window, choose
Tasks >SQL Plan >Create SQL Plan .In the
Create SQL Plan panel, specify the following information.Parameter Description Database SQL Content You can specify SQL content in either of the following ways: -
SQL Entry : This is the default way to specify SQL content. You can directly write the SQL script in the editing area.- The maximum size of the SQL statements that can be entered in the SQL window is limited to 10 MB. If the content to be entered is more than 10 MB in size, you can directly upload an attachment.
- 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.- 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.
Delimiter The delimiters are supported. Query Result Limit You can set the maximum number of rows allowed in the query result. Value range: 1 to 1000000. Execution Timeout Value Specify the value in the Execution Timeout Value field in hours. Default value: 48. Maximum value: 480.Scheduled Period - You can directly select a predefined option of Every Hour, Every Night, or Every Friday.
- You can also set the scheduled execution period in either of the following modes:
- Default: You can set the scheduled execution period on a daily, weekly, or monthly basis as needed.
- Custom: You can set the scheduled execution period by specifying the second, minute, hour, day, month, or week as needed.
Task Settings - Select a task error handling method.
- 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 statement where an error occurs and continues to execute other statements in the script.
- Select the task handling mode when the task execution period exceeds the specified cycle:
- You can choose to initiate the task for a new cycle after the current task is executed.
- Or, you can choose to ignore the current task status and initiate the task periodically.
Remarks (Optional) You can enter a description of up to 200 characters. -
Click
Create .
View SQL plan tasks
Task list
Note
The task list displays the tasks created in the last 336 hours.
After you enter the target database connection, click
After the task is generated, the
The following table describes the columns contained in the task list on this tab. You can filter and sort the tasks in the list.
| Parameter | Description |
|---|---|
| No. | The ID of the task. You can click the search icon to search for and filter tasks by ID. |
| Connection | The name of the database connection to which the task belongs. You can click the filter icon to filter tasks by connection. |
| Execution Period | - |
| Next Execution Time | The time when the SQL plan task is to be executed the next time. |
| Created By | The user who created the task. You can click the search icon to search for rules created by a specific user. |
| Updated At | The date and time when the task was generated. |
| Status | The current status of the task. ODC provides different management actions for tasks in different states. |
| Actions | The task management actions, including
|
Task information
Click
Task Center in the top navigation bar, and click theSQL Plan tab. In the task list on the tab, clickView in the Actions column of the target task to view its details.In the
Task Details panel, click theTask Information tab to view the basic task information and task settings.Parameter Description Basic task information You can view the task status, task ID, task type, connection, remarks, creator, and creation time. Task settings You can view the SQL content, scheduled execution period, next execution time, delimiter, query result limit, error handling method, and execution timeout period.
Execution records
In the
Operating records
In the
to search for and filter tasks by ID.
to filter tasks by connection.