Search

EP-4742057-A1 - DDL STATEMENT CONVERSION METHOD FOR INCREMENTAL DATA MIGRATION, AND RELATED DEVICE

EP4742057A1EP 4742057 A1EP4742057 A1EP 4742057A1EP-4742057-A1

Abstract

This specification provides a method for transforming DDL statements in incremental data migration and a related device. The method includes: in response to triggering an incremental data migration task between a source database and a target database, obtaining a source DDL statement that has been executed in the source database and that complies with syntax rules of the source database; parsing the source DDL statement to obtain operation information that pertains to the source database and that is contained in the source DDL statement, and transforming the operation information into a corresponding structure based on a predefined data format; and transforming the structure into a target DDL statement that complies with syntax rules of the target database, and executing the target DDL statement in the target database.

Inventors

  • BI, Wei
  • ZHENG, Longpeng
  • XU, JING

Assignees

  • Beijing Oceanbase Technology Co., Ltd.

Dates

Publication Date
20260513
Application Date
20240705

Claims (11)

  1. A method for transforming DDL statements in incremental data migration, wherein the method comprises: in response to triggering an incremental data migration task between a source database and a target database, obtaining a source DDL statement that has been executed in the source database and that complies with syntax rules of the source database; parsing the source DDL statement to obtain operation information that pertains to the source database and that is contained in the source DDL statement, and transforming the operation information into a corresponding structure based on a predefined data format; and transforming the structure into a target DDL statement that complies with the syntax rules of the target database, and executing the target DDL statement in the target database.
  2. The method according to claim 1, wherein transforming the structure into a target DDL statement that complies with the syntax rules of the target database comprises: parsing the structure to obtain the operation information contained in the structure; and upon determining that at least partial operation information in the operation information does not comply with the syntax rules of the target database, performing a syntactic transformation on the at least partial operation information, and generating, based on syntactically transformed operation information, the target DDL statement that complies with the syntax rules of the target database.
  3. The method according to claim 2, wherein the operation information comprises information about an operation object that is contained in the source DDL statement and an operation type related to the operation object.
  4. The method according to claim 3, wherein the information about the operation object comprises a combination of one or more of the following: a type, an object identifier, and attribute information of the operation object; and the operation type is any one of a drop operation, an alter operation, and a create operation.
  5. The method according to claim 4, wherein the attribute information of the operation object comprises a data type; and the syntactic transformation comprises a data type transformation.
  6. The method according to claim 1, wherein the source database comprises a pre-built DDL parser matching the syntax rules of the source database and the predefined data format; and parsing the source DDL statement to obtain operation information that pertains to the source database and that is contained in the source DDL statement, and transforming the operation information into a corresponding structure based on a predefined data format comprises: parsing, using the DDL parser in the source database, the source DDL statement to obtain the operation information that pertains to the source database and that is contained in the source DDL statement, and transforming the operation information into the corresponding structure based on the predefined data format.
  7. The method according to claim 1, wherein the target database comprises a pre-built DDL builder matching the syntax rules of the target database and the predefined data format; and transforming the structure into a target DDL statement that complies with the syntax rules of the target database comprises: transforming, using the DDL builder in the target database, the structure into the target DDL statement that complies with the syntax rules of the target database.
  8. The method according to any one of claims 1 to 7, wherein the source database and the target database are heterogeneous databases of different database types.
  9. An apparatus for transforming DDL statements in incremental data migration, comprising: an obtaining unit, configured to: in response to triggering an incremental data migration task between a source database and a target database, obtain a source DDL statement that has been executed in the source database and that complies with syntax rules of the source database; a parsing unit, configured to: parse the source DDL statement to obtain operation information that pertains to the source database and that is contained in the source DDL statement, and transform the operation information into a corresponding structure based on a predefined data format; and a transformation unit, configured to: transform the structure into a target DDL statement that complies with the syntax rules of the target database, and execute the target DDL statement in the target database.
  10. A computer device, comprising a memory and a processor, wherein the memory stores a computer program executable by the processor, and the processor, when executing the computer program, performs the method according to any one of claims 1 to 8.
  11. A computer-readable storage medium, having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method according to any one of claims 1 to 8.

Description

TECHNICAL FIELD One or more embodiments of this specification relate to the field of data migration technologies, and in particular, to a method for transforming DDL statements in incremental data migration and a related device. BACKGROUND A data definition language (DDL) enables a series of operations on objects in a database, for example, creating data tables, altering data tables, and dropping data tables. Therefore, during incremental data migration between a source database and a target database, DDL statements executed in the source database need to be accurately synchronized to the target database to ensure consistency between the target database and the source database. However, if the source database and the target database are heterogeneous databases of different database types, syntactic compatibility issues arise during DDL statement synchronization. That is, a DDL statement that can be executed correctly in the source database may fail to be executed correctly in the target database because the DDL statement does not comply with syntax rules of the target database, thereby severely compromising the consistency between the target database and the source database. SUMMARY In view of this, one or more embodiments of this specification provide a method for transforming DDL statements in incremental data migration and a related device. According to a first aspect, this specification provides a method for transforming DDL statements in incremental data migration. The method includes: in response to triggering an incremental data migration task between a source database and a target database, obtaining a source DDL statement that has been executed in the source database and that complies with syntax rules of the source database; parsing the source DDL statement to obtain operation information that pertains to the source database and that is contained in the source DDL statement, and transforming the operation information into a corresponding structure based on a predefined data format; and transforming the structure into a target DDL statement that complies with the syntax rules of the target database, and executing the target DDL statement in the target database. According to a second aspect, this specification provides an apparatus for transforming DDL statements in incremental data migration, including: an obtaining unit, configured to: in response to triggering an incremental data migration task between a source database and a target database, obtain a source DDL statement that has been executed in the source database and that complies with syntax rules of the source database; a parsing unit, configured to: parse the source DDL statement to obtain operation information that pertains to the source database and that is contained in the source DDL statement, and transform the operation information into a corresponding structure based on a predefined data format; and a transformation unit, configured to: transform the structure into a target DDL statement that complies with the syntax rules of the target database, and execute the target DDL statement in the target database. Correspondingly, this specification further provides a computer device, including a memory and a processor, where the memory stores a computer program executable by the processor, and the processor, when executing the computer program, performs the foregoing method for transforming DDL statements in incremental data migration in the first aspect. Correspondingly, this specification further provides a computer-readable storage medium, having a computer program stored thereon, where the computer program, when executed by a processor, performs the foregoing method for transforming DDL statements in incremental data migration in the first aspect. In summary, during incremental data migration between a source database and a target database that are heterogeneous, in this application, a source DDL statement that is executed in the source database and that complies with syntax rules of the source database may be first transformed into a generic structure. The structure may describe operation information contained in the source DDL statement based on a predefined data format. A target DDL statement that complies with syntax rules of the target database is then further generated based on the operation information described in the structure, and the target DDL statement is executed in the target database. In this way, an intermediate structure serves as the bridge for syntactic transformation between the source DDL statement and the target DDL statement in this application, so that differences between syntax rules of every source database and target database no longer need to be considered, thereby significantly improving the transformation efficiency of DDL statements between heterogeneous databases and reducing the transformation costs of DDL statements. BRIEF DESCRIPTION OF THE DRAWINGS FIG. 1 is a schematic diagram of a system architectu