This topic introduces how to generate, view, and download mock data.
Background information
OceanBase Developer Center (ODC) provides the data mocking feature for you to quickly generate data based on the field types of an existing table in scenarios that require a large amount of mock data, such as database performance testing and feature verification.
Considerations
At most 100 million rows can be mocked at a time.
Data mocking is not supported for a table with
CHECK
constraints.Data mocking is not supported for RANGE- or LIST-partitioned tables.
Data mocking is not supported for a table that is encoded by using ZHSGB2312.
Create a data mocking task
Example: On the Tickets tab, generate mock data based on an existing table in the database.
Parameter | Example value |
Project name | odc_4.2.0 |
Database name | odc_test |
Table name | employee |
In the SQL window, choose Tickets > Mock Data > Create Mock Data Task.
In the Create Mock Data Task panel, configure the following parameters.
Parameter
Description
Database
Select the target database
odc_test
.Table
Select the
employee
table in theodc_test
database to generate mock data based on this table.Mock Data Volume
Specify the number of rows to be generated. The default value is
1000
. At most 100 million rows can be generated. You can enter a value ranging from 1 to 100,000,000.Batch Size
Specify the number of rows that triggers a commit by using the
COMMIT
command. By default, a commit is performed each time when 200 rows are generated. The maximum value is500
. You can enter an integer ranging from 1 to 500.Truncate Table Before Inserting Mock Data
Specify whether to clear the original data before inserting mock data into the table.
Data Conflict Handling Mode
Select the handling method when the inserted data conflicts with the original data in the table. Valid values:
Ignore: This option is selected by default. The data conflicting with existing data is not inserted.
Overwrite: If a data conflict occurs, the original data is deleted, and the new data is inserted.
Terminate: If a data conflict occurs, the data mocking task is terminated.
Rule Settings
Set the data generation rules.
In the Rule and Rule Details columns, set the mock data generation rules for the fields in the selected table. Some built-in rules are provided in the Rule column based on the field type. The Rule Details column displays the details about the selected rule. You can click the Edit icon to edit the details.
Task Settings
Select Execute Now or Scheduled Execution.
Click Submit to generate a data mocking task.
After the task is generated, the Tickets tab automatically appears, where you can view the approval status and basic information of the task.
View a data mocking task
Task information
In the data mocking task list on the Tickets tab, click View in the Actions column of the target task. In the Task Details panel of the target task, click the Task Information tab in the upper-right corner to view the basic task information and data mocking settings.
Item
Description
Basic task information
The ID, connection, database, type, execution mode, creator, and creation time of the task are displayed.
Data mocking settings
The target table, number of rows to generate, number of rows committed at a time, whether to truncate the table before inserting data, handling method for data conflicts, inserted records, conflict records, whether to ignore data conflicts, cleanup records, and rule settings are displayed.
On the Task Information tab, click Initiate Again or Download in the lower-right corner to initiate the task again or download the mock data file to your local disk.
Task logs
In the data mocking task list on the Tickets tab, click View in the Actions column of the target task. In the Task Details panel of the task, click the Task Logs tab in the upper-right corner 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. |
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. |
In addition, the toolbar provides the following icons:
Icon | Description |
Search | Click this icon to search for logs. |
Download | Click this icon to download logs. |
Copy | Click this icon to copy logs. |
Download mock data
In the data mocking task list on the Tickets tab, click Download in the Ticket Details panel of the task to download the created mock data to your local disk. You can view the exported mock data file in your local disk.