Updated on 2026-06-26 GMT+08:00

Data Change

This topic describes the rules and suggestions for changing Doris data.

Doris Data Change Rules

  • Do not frequently perform the update, delete, or truncate operation. Perform an operation every several minutes. To use the update operation, you must set the partitioning condition or primary key column.
  • Do not directly use the delete or update statement to change data. Instead, use the upsert of the CDC.
  • Avoid frequently adding or deleting fields in tables during peak hours. Reserve fields for future use when you create tables. If fields must be added or deleted, or field types and comments must be modified, stop writing and modifying tasks on the target table during off-peak hours and then re-create a table.
    1. Create a table. The structure of the table is the same as that of the table you want to modify. Add new fields to the new table, delete unnecessary fields, or change field types.
    2. Specify fields and insert them to the newly created table.
      INSERT INTO Newly created table SELECT Specified fields FROM Existing table whose columns need to be modified;

      To reduce high CPU or memory usage and minimize the impact on query service, you can import data to a new table in batches based on time if the table has a significant amount of data. The command is as follows:

      insert into tab1 select col from tab where date <= xx;
    3. Exchange the names of the two tables.
      ALTER TABLE [db.]tbl1 REPLACE WITH TABLE tbl2 [PROPERTIES('swap' = 'true')];
  • Do not use the build index operation to create indexes for the entire table or partition.