CN109492000A - A kind of clone method and system of database table - Google Patents

A kind of clone method and system of database table Download PDF

Info

Publication number
CN109492000A
CN109492000A CN201811186579.XA CN201811186579A CN109492000A CN 109492000 A CN109492000 A CN 109492000A CN 201811186579 A CN201811186579 A CN 201811186579A CN 109492000 A CN109492000 A CN 109492000A
Authority
CN
China
Prior art keywords
table data
data blocks
data block
copy
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201811186579.XA
Other languages
Chinese (zh)
Inventor
马国良
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201811186579.XA priority Critical patent/CN109492000A/en
Publication of CN109492000A publication Critical patent/CN109492000A/en
Pending legal-status Critical Current

Links

Classifications

    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00—Error detection; Error correction; Monitoring
    • G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14—Error detection or correction of the data by redundancy in operations
    • G06F11/1446—Point-in-time backing up or restoration of persistent data
    • G06F11/1448—Management of the data involved in backup or backup restore
    • G06F11/1453—Management of the data involved in backup or backup restore using de-duplication of the data
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00—Arrangements for program control, e.g. control units
    • G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46—Multiprogramming arrangements
    • G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Quality & Reliability (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请公开了一种数据库表的复制方法及系统,该方法首先获取与源表相匹配的所有表数据块,然后复制所有表数据块并将其存储至目标表的存储区域,最后根据目标表的存储地址和目标表名,更新所有表数据块的块头和表目录,从而完成数据库表的复制。该系统包括表数据块获取模块、复制模块和更新模块。本申请采用数据块复制的方式实现表数据复制,避免了先读取数据块中的表记录再将表记录插入数据块的传统迁移过程,能够大大提高数据库表的复制效率,而且由于没有表记录读取和插入操作,还有利于节省CPU资源。

The present application discloses a method and system for replicating a database table. The method first acquires all table data blocks matching the source table, then copies all table data blocks and stores them in the storage area of the target table, and finally according to the target table The storage address and target table name are updated, and the block header and table directory of all table data blocks are updated, thereby completing the replication of the database table. The system includes a table data block acquisition module, a replication module and an update module. The application adopts the method of data block replication to realize table data replication, which avoids the traditional migration process of reading table records in data blocks and then inserting table records into data blocks, which can greatly improve the replication efficiency of database tables, and because there are no table records Read and insert operations are also beneficial to save CPU resources.

Description

一种数据库表的复制方法及系统Method and system for copying database table

技术领域technical field

本申请涉及数据库技术领域,特别是涉及一种数据库表的复制方法及系统。The present application relates to the technical field of databases, and in particular, to a method and system for replicating database tables.

背景技术Background technique

在数据库的使用过程中,经常会遇到将一张表的数据完全复制到另一张表的情况,也就是数据库表的复制。In the process of using the database, it is often encountered that the data of one table is completely copied to another table, that is, the replication of the database table.

目前数据库表的复制方法,通常是采用表查询记录再插入的方式。具体地,数据库提供了类似create table XX as select*from YY语句的方法用于创建表及复制数据,执行该语句后,首先从初始表中使用select查询出表记录,读取表记录,然后再将表记录一条一条插入到新表,直到完成整个表的复制。The current method of copying database tables is usually the method of querying records from tables and inserting them. Specifically, the database provides a method similar to the create table XX as select*from YY statement for creating tables and copying data. After executing the statement, first use select to query the table records from the initial table, read the table records, and then Insert table records one by one into the new table until the entire table is copied.

然而,目前数据库表的复制方法中,由于需要在初始表中查询出每个表记录并逐个插入新表中,初始表越大查询速度就会越慢,而且源表越大复制过程对系统I/O占用就会越多,从而对系统I/O造成压力,长时间的大表查询也会占用更多CPU资源,造成对CPU资源的消耗。因此,目前复制表的方式效率不够高且占用CPU资源较多。However, in the current database table replication method, since each table record needs to be queried in the initial table and inserted into the new table one by one, the larger the initial table is, the slower the query speed will be, and the larger the source table, the slower the replication process will be for the system I. The more /O is occupied, which will put pressure on the system I/O. Long-term large table queries will also occupy more CPU resources, resulting in CPU resource consumption. Therefore, the current method of copying tables is not efficient enough and occupies a lot of CPU resources.

发明内容SUMMARY OF THE INVENTION

本申请提供了一种数据库表的复制方法及系统,以解决现有技术中数据库表的复制效率低且占用CPU资源较多的问题。The present application provides a method and system for replicating a database table, so as to solve the problems in the prior art that the replication efficiency of the database table is low and occupies more CPU resources.

为了解决上述技术问题,本申请实施例公开了如下技术方案:In order to solve the above technical problems, the embodiments of the present application disclose the following technical solutions:

一种数据库表的复制方法,所述方法包括:A method for replicating a database table, the method comprising:

S1:获取与源表相匹配的所有表数据块;S1: Get all table data blocks that match the source table;

S2:复制所述所有表数据块,并将所述所有表数据块存储至目标表的存储区域;S2: copy all the table data blocks, and store the all table data blocks in the storage area of the target table;

S3:根据所述目标表的存储地址和目标表名,更新所述所有表数据块的块头和表目录。S3: Update the block headers and table directories of all table data blocks according to the storage address of the target table and the target table name.

可选地,步骤S2包括:Optionally, step S2 includes:

S21:一次性复制所述所有表数据块,并将所述所有表数据块存储至目标表的存储区域;或者,S21: Copy all the table data blocks at one time, and store all the table data blocks in the storage area of the target table; or,

S22:采用可增量同步复制的方法复制所述所有表数据块,并将所述所有表数据块存储至目标表的存储区域。S22: Copy all the table data blocks by using the incremental synchronous replication method, and store all the table data blocks in the storage area of the target table.

可选地,步骤S21包括:Optionally, step S21 includes:

S211:根据所获取的表复制命令create table XX copy from YY获取源表结构,并创建目标表;S211: Obtain the source table structure according to the obtained table copy command create table XX copy from YY, and create the target table;

S212:根据第一参数所设定的表数据块个数,依次读取并复制源表存储区域中的表数据块,所述第一参数用于设定一次读取复制的表数据块个数。S212: Read and copy the table data blocks in the source table storage area in turn according to the number of table data blocks set by the first parameter, where the first parameter is used to set the number of table data blocks to be read and copied at one time .

可选地,所述第一参数设定的一次读取的表数据块个数为64。Optionally, the number of table data blocks read at one time set by the first parameter is 64.

可选地,步骤S22包括:Optionally, step S22 includes:

S221:根据所获取的表复制命令create table XX integrate copy from YY获取源表结构,并创建目标表;S221: Obtain the source table structure according to the obtained table copy command create table XX integrate copy from YY, and create the target table;

S222:根据第一参数所设定的表数据块个数,依次读取并复制源表存储区域中的表数据块;S222: Read and copy the table data blocks in the source table storage area in turn according to the number of table data blocks set by the first parameter;

S223:当被读取后的表数据块中的表记录发生变化时,根据第二参数将发生变化的表数据块记录至表数据块变化记录文件中,所述第二参数用于设定表数据块变更记录文件所在的路径及文件名;S223: When the table record in the read table data block changes, record the changed table data block in the table data block change record file according to a second parameter, where the second parameter is used to set the table The path and file name of the data block change record file;

S224:根据所获取的表增量同步命令start integrate incr copy,按照时间顺序依次读取所述表数据块变化记录文件中的表数据块,并将所述表数据块变化记录文件中的表数据块依次同步至目标表;S224: According to the obtained table incremental synchronization command start integrate incr copy, sequentially read the table data blocks in the table data block change record file in chronological order, and convert the table data blocks in the table data block change record file The blocks are synchronized to the target table in turn;

S225:删除所述表数据块变化记录文件中读取后的表数据块。S225: Delete the read table data block in the table data block change record file.

S226:返回步骤S223,直到目标表中的表数据块和源表中的表数据块完全一致为止。S226: Return to step S223 until the table data block in the target table is completely consistent with the table data block in the source table.

可选地,所述表数据块变化记录文件的存储内容包括:变化的表数据块、表数据块发生变化的时间戳以及变化的表数据块所属的用户和表名,且所述存储内容按照时间顺序进行存储。Optionally, the storage content of the table data block change record file includes: the changed table data block, the time stamp of the change in the table data block, and the user and table name to which the changed table data block belongs, and the storage content is according to are stored in chronological order.

一种数据库表的复制系统,所述系统包括:A system for replicating a database table, the system comprising:

表数据块获取模块,用于获取与源表相匹配的所有表数据块;The table data block obtaining module is used to obtain all table data blocks matching the source table;

复制模块,用于复制所述所有表数据块,并将所述所有表数据块存储至目标表的存储区域;a copying module for copying all the table data blocks and storing the all table data blocks in the storage area of the target table;

更新模块,用于根据所述目标表的存储地址和目标表名,更新所述所有表数据块的块头和表目录。An update module, configured to update the block headers and table directories of all the table data blocks according to the storage address of the target table and the target table name.

可选地,所述复制模块包括:第一复制单元或第二复制单元;Optionally, the replication module includes: a first replication unit or a second replication unit;

所述第一复制单元,用于一次性复制所述所有表数据块,并将所述所有表数据块存储至目标表的存储区域;the first copying unit, configured to copy all the table data blocks at one time, and store the all table data blocks in the storage area of the target table;

所述第二复制单元,用于采用可增量同步复制的方法复制所述所有表数据块,并将所述所有表数据块存储至目标表的存储区域。The second copying unit is configured to copy all the table data blocks by adopting the method of incremental synchronous replication, and store all the table data blocks in the storage area of the target table.

可选地,所述第一复制单元包括:Optionally, the first replication unit includes:

第一目标表创建子单元,用于根据所获取的表复制命令create table XX copyfrom YY获取源表结构,并创建目标表;The first target table creation subunit is used to obtain the source table structure according to the obtained table copy command create table XX copyfrom YY, and create the target table;

第一读取和复制子单元,用于根据第一参数所设定的表数据块个数,依次读取并复制源表存储区域中的表数据块,所述第一参数用于设定一次读取复制的表数据块个数。The first reading and copying subunit is used to sequentially read and copy the table data blocks in the source table storage area according to the number of table data blocks set by the first parameter, and the first parameter is used to set once Read the number of replicated table data blocks.

可选地,所述第二复制单元包括:Optionally, the second replication unit includes:

第二目标表创建子单元,用于根据所获取的表复制命令create table XXintegrate copy from YY获取源表结构,并创建目标表;The second target table creation subunit is used to obtain the source table structure according to the obtained table copy command create table XXintegrate copy from YY, and create the target table;

第二读取和复制子单元,用于根据第一参数所设定的表数据块个数,依次读取并复制源表存储区域中的表数据块;The second reading and copying subunit is used for sequentially reading and copying the table data blocks in the source table storage area according to the number of table data blocks set by the first parameter;

变化记录子单元,用于当被读取后的表数据块中的表记录发生变化时,根据第二参数将发生变化的表数据块记录至表数据块变化记录文件中,所述第二参数用于设定表数据块变更记录文件所在的路径及文件名;The change record subunit is used to record the changed table data block in the table data block change record file according to the second parameter when the table record in the read table data block changes, the second parameter Used to set the path and file name of the table data block change record file;

增量同步子单元,用于根据所获取的表增量同步命令start integrate incrcopy,按照时间顺序依次读取所述表数据块变化记录文件中的表数据块,并将所述表数据块变化记录文件中的表数据块同步至目标表;The incremental synchronization subunit is used to sequentially read the table data blocks in the table data block change record file according to the obtained table incremental synchronization command start integrate incrcopy, and record the table data block changes The table data blocks in the file are synchronized to the target table;

清除子单元,用于删除所述表数据块变化记录文件中读取后的表数据块;Clearing the subunit for deleting the table data block read in the table data block change record file;

循环子单元,用于执行表复制命令create table XX integrate copy from YY期间,源表数据块中的表记录再次发生变化,以及执行表增量同步命令start integrateincr copy期间,已经同步的表数据块再次发生变化时,重新启动变化记录子单元、增量同步子单元以及清除子单元,直到目标表中的表数据块和源表中的表数据块完全一致为止。The loop subunit is used to execute the table copy command create table XX integrate copy from YY, the table records in the source table data block change again, and during the execution of the table incremental synchronization command start integrateincr copy, the table data block that has been synchronized changes again. When a change occurs, restart the change record subunit, incremental synchronization subunit, and clear subunit until the table data blocks in the target table and the table data blocks in the source table are exactly the same.

本申请的实施例提供的技术方案可以包括以下有益效果:The technical solutions provided by the embodiments of the present application may include the following beneficial effects:

本申请提供一种数据库表的复制方法,该方法首先获取与源表相匹配的所有表数据块,然后直接复制所有表数据块,并将所有表数据块存储至目标表的存储区域,最后根据目标表的存储地址和目标表名,更新所有表数据块的块头和表目录,从而完成数据库表的复制。本申请采用数据块复制的方式实现表数据复制,避免了读取数据块中的表记录以及将表记录插入数据块的过程,因此,能够大大提高数据库表的复制效率,而且由于没有表记录读取和插入操作,还有利于节省CPU资源占用。另外,本申请中进行数据块复制时,提供两种复制方式:一种是一次性复制所有表数据块,并将所有表数据块存储至目标表的存储区域,该复制方式适用于静态表的复制,能够大大提高复制效率;另一种是采用可增量同步复制的方式,在全表复制过程中当一个表数据块被读取后如果又发生了变化,该变化的表数据块会记录到表数据块变化记录文件,待表增量同步时会将该文件中的表数据块同步到目标表,这种方式能够进一步提高源表数据和目标表数据的一致性,从而提高复制的准确性。The present application provides a method for copying a database table. The method first obtains all table data blocks matching the source table, then directly copies all table data blocks, and stores all table data blocks in the storage area of the target table, and finally according to The storage address and target table name of the target table are updated, and the block header and table directory of all table data blocks are updated, thereby completing the replication of the database table. The present application adopts the method of data block replication to realize table data replication, which avoids the process of reading table records in data blocks and inserting table records into data blocks. Therefore, the replication efficiency of database tables can be greatly improved, and since there is no table record read Fetch and insert operations are also beneficial to save CPU resources. In addition, when copying data blocks in this application, two copying methods are provided: one is to copy all table data blocks at one time, and store all table data blocks in the storage area of the target table. This copying method is suitable for static tables. Replication can greatly improve the replication efficiency; the other is to use incremental synchronous replication. During the full table replication process, when a table data block is read, if it changes again, the changed table data block will be recorded. To the table data block change record file, the table data blocks in the file will be synchronized to the target table when the table is incrementally synchronized. This method can further improve the consistency of the source table data and the target table data, thereby improving the accuracy of replication. sex.

本申请还提供一种数据库表的复制系统,该系统主要包括表数据块获取模块、复制模块和更新模块。首先通过表数据块获取模块获取到与源表相匹配的所有表数据块,然后通过复制模块复制所有表数据块并将其存储至目标表的存储区域,最后更新模块根据目标表的存储地址和目标表名,更新所有表数据块的块头和表目录。本申请采用数据块复制的方式将表数据从源表复制到目标表,节省了读取数据块中的表记录以及将表记录插入数据块的时间,大大缩短数据复制时间,因此,能够有效提高数据库表的复制效率,而且由于本系统中没有表记录读取和插入操作,还有利于节省CPU资源。The present application also provides a database table replication system, which mainly includes a table data block acquisition module, a replication module and an update module. First, all table data blocks matching the source table are obtained through the table data block acquisition module, then all table data blocks are copied through the copy module and stored in the storage area of the target table, and finally the update module is based on the storage address of the target table and Target table name, update the block header and table directory of all table data blocks. In the present application, the data block copy method is adopted to copy the table data from the source table to the target table, which saves the time for reading the table records in the data block and inserting the table records into the data block, and greatly shortens the data copy time. Therefore, it can effectively improve the The replication efficiency of database tables, and because there is no table in the system to record read and insert operations, is also conducive to saving CPU resources.

应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本申请。It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not limiting of the present application.

附图说明Description of drawings

此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description serve to explain the principles of the application.

为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. In other words, other drawings can also be obtained based on these drawings without creative labor.

图1为本申请实施例所提供的一种数据库表的复制方法的流程示意图;1 is a schematic flowchart of a method for replicating a database table according to an embodiment of the present application;

图2为本申请实施例中数据块的格式示意图;2 is a schematic diagram of the format of a data block in an embodiment of the present application;

图3为本申请实施例所提供的一种数据库表的复制系统的结构示意图。FIG. 3 is a schematic structural diagram of a system for replicating a database table according to an embodiment of the present application.

具体实施方式Detailed ways

为了使本技术领域的人员更好地理解本申请中的技术方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。In order to make those skilled in the art better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described The embodiments are only a part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the scope of protection of the present application.

为了更好地理解本申请,下面结合附图来详细解释本申请的实施方式。For a better understanding of the present application, the embodiments of the present application are explained in detail below with reference to the accompanying drawings.

参见图1,图1为本申请实施例所提供的一种数据库表的复制方法的流程示意图。由图1可知,本实施例中数据库表的复制方法主要包括如下步骤:Referring to FIG. 1 , FIG. 1 is a schematic flowchart of a method for copying a database table according to an embodiment of the present application. As can be seen from Figure 1, the method for replicating the database table in this embodiment mainly includes the following steps:

S1:获取与源表相匹配的所有表数据块。S1: Get all table data blocks that match the source table.

数据库表的复制是指,将源表中的数据复制到目标表中,而数据库表的所有记录都存储在数据块中,因此,需要先获取源表的所有表数据块。Database table replication refers to copying the data from the source table to the target table, and all records of the database table are stored in data blocks. Therefore, it is necessary to obtain all table data blocks of the source table first.

一个数据库表中包含多个数据块,一个数据块只会存储某一个数据库表的记录,不会同时存储不同数据库表的记录,而且一个数据块可以存储一个数据库表的多条记录,甚至可达几百几千条记录。A database table contains multiple data blocks, a data block can only store records of a certain database table, and will not store records of different database tables at the same time, and a data block can store multiple records of a database table, even up to Hundreds of thousands of records.

一个数据块通常为8K大小,数据块的格式可以参见图2。由图2可知,在一个数据块中,根据各部分的不同功能,可以将数据块存储区域划分为块头、表目录、行目录、行数据以及自由空间五个区域,每个区域都有其各自的功能。其中,块头用于存放数据块的基本信息,如:数据块的物理地址,数据块所属段的类型,数据块所属段的类型包括数据段和索引段。表目录用于存放表的信息,即:如果一些表的数据被存放在这个数据块中,那么这些表的相关信息将被存放在“表目录”中。行目录用于记录行的信息,即:如果数据块中有行数据存在,则这些行的信息将被记录在行目录中,其中行的信息包括行的地址等。行数据用于存放表数据和索引数据,是存储表记录的空间。自由空间用于存储行记录,当向数据库表中插入记录时,自由空间会减少。A data block is usually 8K in size, and the format of the data block can be seen in Figure 2. As can be seen from Figure 2, in a data block, according to the different functions of each part, the data block storage area can be divided into five areas: block header, table directory, row directory, row data and free space, and each area has its own function. The block header is used to store basic information of the data block, such as the physical address of the data block, the type of the segment to which the data block belongs, and the type of the segment to which the data block belongs includes the data segment and the index segment. The table directory is used to store table information, that is, if the data of some tables is stored in this data block, the related information of these tables will be stored in the "table directory". The row directory is used to record row information, that is, if row data exists in the data block, the row information will be recorded in the row directory, where the row information includes row addresses and the like. Row data is used to store table data and index data, and is the space for storing table records. Free space is used to store row records, and when records are inserted into database tables, free space is reduced.

获取到源表所匹配的所有的表数据块之后,执行步骤S2:复制所有表数据块,并将所有表数据块存储至目标表的存储区域。After acquiring all the table data blocks matched by the source table, step S2 is performed: copying all the table data blocks, and storing all the table data blocks in the storage area of the target table.

本实施例中复制表数据块的方法包括两种:一种是只进行一次复制,复制过程中变化的表数据不会再进行复制;另一种是可增量同步复制方法。具体地,步骤S2包括如下两种情况:In this embodiment, there are two methods for replicating table data blocks: one is to perform replication only once, and the table data changed during the replication process will not be replicated again; the other is an incremental synchronous replication method. Specifically, step S2 includes the following two situations:

S21:一次性复制所有表数据块,并将所有表数据块存储至目标表的存储区域。S21: Copy all table data blocks at one time, and store all table data blocks in the storage area of the target table.

当源表为静态表时,采用步骤S21中的方法进行复制后,源表和目标表数据完全一致,由于一次性直接复制数据块,避免了读取表记录以及将表记录插入数据块的过程,因此,能够大大提高数据库表的复制效率,而且由于没有表记录读取和插入操作,还能够节省大量的CPU资源。When the source table is a static table, after the method in step S21 is used for replication, the data of the source table and the target table are completely consistent. Since the data block is copied directly at one time, the process of reading the table record and inserting the table record into the data block is avoided. Therefore, the replication efficiency of the database table can be greatly improved, and since there is no table record read and insert operations, a lot of CPU resources can be saved.

具体地,步骤S21包括如下过程:Specifically, step S21 includes the following processes:

S211:根据所获取的表复制命令create table XX copy from YY获取源表结构,并创建目标表。S211: Obtain the source table structure according to the obtained table copy command create table XX copy from YY, and create a target table.

即:根据所获取的表复制命令create table XX copy from YY获取源表结构,然后再根据表复制命令和源表结构创建目标表。源表结构可以通过命令来获取,从而避免手动获取,有利于提高数据复制效率。That is: obtain the source table structure according to the obtained table copy command create table XX copy from YY, and then create the target table according to the table copy command and the source table structure. The source table structure can be obtained through commands, thereby avoiding manual obtaining and improving the efficiency of data replication.

S212:根据第一参数所设定的表数据块个数,依次读取并复制源表存储区域中的表数据块,第一参数用于设定表复制时一次读取的表数据块个数。S212: Read and copy the table data blocks in the source table storage area in turn according to the number of table data blocks set by the first parameter, where the first parameter is used to set the number of table data blocks read at one time during table copying .

由以上步骤S211和S212可知,本实施例中一次性直接复制数据块的方法,采用了表复制命令create table XX copy from YY。该执行命令后,首先根据源表结构创建目标表,然后从表存储的第一个表数据块开始,按第一参数所指定的表数据块个数读取并复制一批表数据块,读取并复制完成后再根据第一参数所指定的表数据块个数进行下一批表数据块的读取和复制,全部表数据块复制完成后返回到命令行。It can be seen from the above steps S211 and S212 that the method for directly copying data blocks at one time in this embodiment adopts the table copy command create table XX copy from YY. After executing the command, first create the target table according to the structure of the source table, then start from the first table data block stored in the table, read and copy a batch of table data blocks according to the number of table data blocks specified by the first parameter, read After the fetching and copying is completed, read and copy the next batch of table data blocks according to the number of table data blocks specified by the first parameter, and return to the command line after all table data blocks are copied.

本实施例中第一参数可以采用参数copy_table_block_count。第一参数所设定的一次读取的表数据块个数,可以根据服务器的存储性能进行调整,如果该参数设置的过小,会频繁地进行存储读取,从而增加存储读取次数影响效率;如果该参数设置过大,则会占用过多内存。本实施例中优选一次读取的表数据块个数为64,即一次读取复制64个表数据块这种参数设置,既能提高数据同步的效率,又不对系统造成压力或产生太大性能影响。In this embodiment, the first parameter may use the parameter copy_table_block_count. The number of table data blocks read at one time set by the first parameter can be adjusted according to the storage performance of the server. If this parameter is set too small, storage reads will be performed frequently, thus increasing the number of storage reads and affecting efficiency. ; If this parameter is set too large, it will take up too much memory. In this embodiment, the number of table data blocks read at one time is preferably 64, that is, the parameter setting of 64 table data blocks read and copied at one time can not only improve the efficiency of data synchronization, but also not cause pressure on the system or cause too much performance influences.

采用步骤S21的方法时,表中数据块只被读取并复制一次,适用于静态表的复制。When the method of step S21 is adopted, the data blocks in the table are read and copied only once, which is applicable to the replication of static tables.

当所复制的数据库表为动态表时,本实施例还提供了另一种表复制方法,即步骤S22:采用可增量同步复制的方法复制所有表数据块,并将所有表数据块存储至目标表的存储区域。When the replicated database table is a dynamic table, this embodiment also provides another method for table replication, that is, step S22 : replicate all table data blocks by means of incremental synchronous replication, and store all table data blocks to the target The storage area for the table.

具体地,步骤S22包括如下过程:Specifically, step S22 includes the following processes:

S221:根据所获取的表复制命令create table XX integrate copy from YY获取源表结构,并创建目标表。S221: Obtain the structure of the source table according to the obtained table copy command create table XX integrate copy from YY, and create the target table.

即:根据所获取的表复制命令create table XX integrate copy from YY获取源表结构,然后再根据表复制命令create table XX integrate copy from YY和源表结构创建目标表。That is: obtain the source table structure according to the obtained table copy command create table XX integrate copy from YY, and then create the target table according to the table copy command create table XX integrate copy from YY and the source table structure.

S222:根据第一参数所设定的表数据块个数,依次读取并复制源表存储区域中的表数据块。S222: Read and copy the table data blocks in the source table storage area in sequence according to the number of table data blocks set by the first parameter.

S223:当被读取后的表数据块中的表记录发生变化时,根据第二参数将发生变化的表数据块记录至表数据块变化记录文件中,第二参数用于设定表数据块变更记录文件所在的路径及文件名。S223: when the table record in the read table data block changes, record the changed table data block in the table data block change record file according to the second parameter, and the second parameter is used to set the table data block Change the path and file name of the log file.

本实施例中第二参数可以采用参数copy_table_block_change_trace。从开始执行表复制命令create table XX integrate copy from YY进行全表完整复制,到该表复制命令执行完毕期间,当源表中表数据块被读取后又发生变化时,将变化后的表数据块记录到表数据块变化记录文件中。如果在表数据块复制过程中,被复制后的表数据块发生了多次变化,多次变化后的表数据块也会记录到表数据块变化记录文件中。In this embodiment, the second parameter may use the parameter copy_table_block_change_trace. From the start of executing the table copy command create table XX integrate copy from YY to perform a complete copy of the entire table, to the completion of the execution of the table copy command, when the table data block in the source table changes after being read, the changed table data will be Blocks are logged to the table data block change log file. If during the table data block copying process, the copied table data block has changed many times, the table data block after multiple changes will also be recorded in the table data block change record file.

表数据块变化记录文件中存储的内容包括:变化的表数据块、表数据块发生变化的时间戳以及变化的表数据块所属的用户和表名,且存储内容按照时间顺序进行存储。本实施例中可以同时对不同的数据库表进行复制,当同时对不同数据库表进行全表完整复制时,不同数据库表的变化表数据块会以时间顺序全部记录到表数据块变化记录文件中。The content stored in the table data block change record file includes: the changed table data block, the time stamp of the change of the table data block, and the user and table name to which the changed table data block belongs, and the stored content is stored in chronological order. In this embodiment, different database tables can be replicated at the same time. When full table full replication of different database tables is performed at the same time, the changed table data blocks of different database tables are all recorded in the table data block change record file in chronological order.

S224:根据所获取的表增量同步命令start integrate incr copy,按照时间顺序依次读取表数据块变化记录文件中的表数据块,并将表数据块变化记录文件中的表数据块依次同步至目标表。S224: According to the obtained table incremental synchronization command start integrate incr copy, sequentially read the table data blocks in the table data block change record file in chronological order, and sequentially synchronize the table data blocks in the table data block change record file to target table.

执行表增量同步命令start integrate incr copy之后,会将表数据块变化记录文件中所记录的变化表数据块以时间顺序同步到相应的目标表中。如果该标增量同步命令还没有完成而此时已经同步的表数据块又发生了变化,则变化后的表数据块再次追加到表数据块变化记录文件中,并再次进行同步。After executing the table incremental synchronization command start integrate incr copy, the change table data blocks recorded in the table data block change record file will be synchronized to the corresponding target table in time sequence. If the incremental synchronization command has not been completed and the synchronized table data block has changed again, the changed table data block is added to the table data block change record file again, and the synchronization is performed again.

S225:删除表数据块变化记录文件中读取后的表数据块。S225: Delete the read table data block in the table data block change record file.

读取表数据块变化记录文件中的表数据块,并将表数据块变化记录文件中的表数据块依次同步至目标表,相当于对目标表的表数据块进行更新,完成数据更新后,及时将表数据块变化记录文件中读取后的表数据块进行清除,从而提高数据库表复制的效率。Read the table data blocks in the table data block change record file, and synchronize the table data blocks in the table data block change record file to the target table in turn, which is equivalent to updating the table data blocks of the target table. After the data update is completed, Clears the read table data blocks in the table data block change record file in time, thereby improving the efficiency of database table replication.

S226:返回步骤S223,直到目标表中的表数据块和源表中的表数据块完全一致为止。S226: Return to step S223 until the table data block in the target table is completely consistent with the table data block in the source table.

执行表复制命令create table XX integrate copy from YY期间,源表表数据块中的表记录再次发生变化时,以及,执行表增量同步命令start integrate incr copy期间,已经同步的表数据块再次发生变化时,重新返回步骤S223,即:再次执行步骤S223、S224和S225,直到目标表中的表数据块和源表中的表数据块完全一致为止。During the execution of the table copy command create table XX integrate copy from YY, when the table records in the table data block of the source table change again, and during the execution of the table incremental synchronization command start integrate incr copy, the synchronized table data block changes again , return to step S223, that is, execute steps S223, S224 and S225 again, until the table data block in the target table is completely consistent with the table data block in the source table.

由以上步骤S221-S226可知,本实施例可增量同步复制的方法中,采用了表复制命令create table XX integrate copy from YY。执行该命令后,首先会根据源表结构创建目标表,然后从表存储的第一个表数据块开始,按照第一参数所指定的表数据块个数依次读取并复制表数据块。如果表数据块在被读取后,其中的表记录发生了变化,则表记录发生变化的表数据块会被记录到第二参数所指定的文件中,本实施例中第二参数所指定的文件即表数据块变化记录文件。显然,当数据库表被复制完成后,第二参数指定的文件中可能会记录了多个表数据块。为了使变化的表数据块能够同步到目标表,本实施例采用表增量步命令start integrate incr copy,该命令执行后会以时间顺序读取copy_table_block_change_trace参数所指定的表数据块变化记录文件,将表数据块变化记录文件中变化的表数据块同步到目标表,最后,读取后的表数据块会从表数据块变化记录文件中删除,直到将表数据块变化记录文件中最后一个表数据块处理完毕,返回命令行,变化表数据块同步完毕。It can be seen from the above steps S221-S226 that, in the method for incremental synchronous replication in this embodiment, the table replication command create table XX integrate copy from YY is adopted. After the command is executed, the target table will be created according to the structure of the source table, and then, starting from the first table data block stored in the table, the table data blocks will be read and copied in sequence according to the number of table data blocks specified by the first parameter. If the table records in the table data block are changed after being read, the table data block whose table records are changed will be recorded in the file specified by the second parameter. In this embodiment, the table data block specified by the second parameter The file is the table data block change record file. Obviously, after the database table is copied, multiple table data blocks may be recorded in the file specified by the second parameter. In order to synchronize the changed table data blocks to the target table, this embodiment adopts the table incremental step command start integrate incr copy. After the command is executed, the table data block change record file specified by the copy_table_block_change_trace parameter will be read in chronological order, and the The table data blocks changed in the table data block change record file are synchronized to the target table. Finally, the read table data blocks will be deleted from the table data block change record file until the last table data in the table data block change record file is deleted. After the block is processed, return to the command line, and the synchronization of the change table data block is completed.

本实施通过将变化的表数据块会记录到表数据块变化记录文件,待表增量同步时将该文件中的表数据块同步到目标表中,能够进一步提高源表数据和目标表数据的一致性,从而提高复制的准确性。而且本实施例中设置循环模式,可以进行多次可增量同步复制,从而提高复制准确性和复制效率。In this implementation, the changed table data blocks are recorded in the table data block change record file, and the table data blocks in the file are synchronized to the target table when the table is incrementally synchronized, which can further improve the relationship between the source table data and the target table data. consistency, thereby improving the accuracy of replication. In addition, the cyclic mode is set in this embodiment, and multiple incremental synchronous replication can be performed, thereby improving the replication accuracy and replication efficiency.

S3:根据目标表的存储地址和目标表名,更新所有表数据块的块头和表目录。S3: Update the block headers and table directories of all table data blocks according to the storage address of the target table and the target table name.

本实施例中目标表的存储地址,指的是目标表中表数据块的实际存储地址。将复制的所有表数据块存储至目标表的存储区域后,将新的表数据块存储地址写入目标表的表数据块块头中,将目标表的表数据块表目录中的表名修改为目标表名。通过执行步骤S3,将新数据块变成目标表的一个数据块,查询目标表数据时会从这些新数据块中读取相应行记录。The storage address of the target table in this embodiment refers to the actual storage address of the table data block in the target table. After all the copied table data blocks are stored in the storage area of the target table, write the new table data block storage address into the table data block header of the target table, and change the table name in the table data block table directory of the target table to Target table name. By executing step S3, the new data block is turned into a data block of the target table, and corresponding row records are read from these new data blocks when querying the data of the target table.

在图1和图2所示实施例的基础之上参见图3,图3为本申请实施例所提供的一种数据库表的复制系统的结构示意图。由图3可知,本申请中数据库表的复制系统主要包括表数据块获取模块、复制模块和更新模块三部分。其中,表数据块获取模块用于获取与源表相匹配的所有表数据块;复制模块用于复制所有表数据块,并将所有表数据块存储至目标表的存储区域;更新模块用于根据目标表的存储地址和目标表名,更新所有表数据块的块头和表目录。Referring to FIG. 3 on the basis of the embodiments shown in FIG. 1 and FIG. 2 , FIG. 3 is a schematic structural diagram of a database table replication system provided by an embodiment of the present application. It can be seen from FIG. 3 that the replication system of the database table in this application mainly includes three parts: a table data block acquisition module, a replication module and an update module. Among them, the table data block acquisition module is used to obtain all table data blocks that match the source table; the copy module is used to copy all table data blocks and store all table data blocks in the storage area of the target table; the update module is used to The storage address and target table name of the target table, update the block header and table directory of all table data blocks.

复制模块又包括第一复制单元或第二复制单元,第一复制单元用于静态表复制,第二复制单元用于动态表复制。具体地,第一复制单元用于一次性复制所有表数据块,并将所有表数据块存储至目标表的存储区域;第二复制单元用于采用可增量同步复制的方法复制所有表数据块,并将所有表数据块存储至目标表的存储区域。The replication module further includes a first replication unit or a second replication unit, the first replication unit is used for static table replication, and the second replication unit is used for dynamic table replication. Specifically, the first copying unit is used for copying all table data blocks at one time, and storing all table data blocks in the storage area of the target table; the second copying unit is used for copying all table data blocks by adopting the method of incremental synchronous copying , and store all table data blocks to the storage area of the target table.

进一步地,第一复制单元包括:第一目标表创建子单元和第一读取和复制子单元。第一目标表创建子单元用于用于根据所获取的表复制命令create table XX copy fromYY获取源表结构,并创建目标表;第一读取和复制子单元用于根据第一参数所设定的表数据块个数,依次读取并复制源表存储区域中的表数据块,第一参数用于设定一次读取复制的表数据块个数。Further, the first copying unit includes: a first target table creation subunit and a first reading and copying subunit. The first target table creation subunit is used for obtaining the source table structure according to the obtained table copy command create table XX copy fromYY, and creates the target table; the first reading and copying subunit is used for setting according to the first parameter The number of table data blocks in the source table is read and copied in turn. The first parameter is used to set the number of table data blocks to be read and copied at one time.

第二复制单元包括:第二目标表创建子单元、第二读取和复制子单元、变化记录子单元、增量同步子单元、清除子单元和循环子单元。其中,第二目标表创建子单元用于根据所获取的表复制命令create table XX integrate copy from YY获取源表结构,并创建目标表;第二读取和复制子单元用于根据第一参数所设定的表数据块个数,依次读取并复制源表存储区域中的表数据块;变化记录子单元用于当被读取后的表数据块中的表记录发生变化时,根据第二参数将发生变化的表数据块记录至表数据块变化记录文件中,第二参数用于设定表数据块变更记录文件所在的路径及文件名;增量同步子单元用于根据所获取的表增量同步命令start integrate incr copy,按照时间顺序依次读取表数据块变化记录文件中的表数据块,并将表数据块变化记录文件中的表数据块同步至目标表;清除子单元用于删除表数据块变化记录文件中读取后的表数据块;循环子单元用于执行表复制命令create table XX integrate copy from YY期间,源表表数据块中的表记录再次发生变化,以及执行表增量同步命令start integrate incr copy期间,已经同步的表数据块再次发生变化时,重新启动变化记录子单元、增量同步子单元以及清除子单元,直到目标表中的表数据块和源表中的表数据块完全一致为止。The second copying unit includes: a second target table creation subunit, a second reading and copying subunit, a change recording subunit, an incremental synchronization subunit, a clearing subunit, and a looping subunit. Wherein, the second target table creation subunit is used to obtain the source table structure according to the obtained table copy command create table XX integrate copy from YY, and create the target table; the second read and copy subunit is used to The set number of table data blocks, read and copy the table data blocks in the source table storage area in turn; the change record subunit is used for when the table records in the read table data block change, according to the second The parameter records the changed table data block to the table data block change record file, and the second parameter is used to set the path and file name where the table data block change record file is located; the incremental synchronization subunit is used to The incremental synchronization command start integrate incr copy reads the table data blocks in the table data block change record file in chronological order, and synchronizes the table data blocks in the table data block change record file to the target table; Delete the read table data block in the table data block change record file; the loop subunit is used to execute the table copy command create table XX integrate copy from YY, the table record in the table data block of the source table changes again, and the execution table During the incremental synchronization command start integrate incr copy, when the synchronized table data block changes again, restart the change record subunit, incremental synchronization subunit, and clear subunit until the table data block in the target table and the source table The table data blocks are completely consistent.

数据库表的复制系统的工作原理和工作方法,在图1和图2所示的数据库表的复制方法中已经详细阐述,在此不再赘述。The working principle and working method of the database table replication system have been described in detail in the database table replication method shown in FIG. 1 and FIG. 2 , and will not be repeated here.

本申请的复制系统采用数据块复制的方式将表数据从源表复制到目标表,能够节省读取数据块中的表记录以及将表记录插入数据块的时间,大大缩短数据复制时间,因此,能够有效提高数据库表的复制效率,而且由于本系统中没有表记录读取和插入操作,还有利于节省CPU资源。The replication system of the present application replicates the table data from the source table to the target table by means of data block replication, which can save the time for reading the table records in the data block and inserting the table records into the data block, and greatly shortens the data replication time. Therefore, It can effectively improve the replication efficiency of database tables, and because there is no table record read and insert operations in the system, it is also beneficial to save CPU resources.

以上所述仅是本申请的具体实施方式,使本领域技术人员能够理解或实现本申请。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此,本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。The above descriptions are only specific embodiments of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, this application is not intended to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1.一种数据库表的复制方法,其特征在于,所述方法包括:1. a replication method of database table, is characterized in that, described method comprises: S1:获取与源表相匹配的所有表数据块;S1: Get all table data blocks that match the source table; S2:复制所述所有表数据块,并将所述所有表数据块存储至目标表的存储区域;S2: copy all the table data blocks, and store the all table data blocks in the storage area of the target table; S3:根据所述目标表的存储地址和目标表名,更新所述所有表数据块的块头和表目录。S3: Update the block headers and table directories of all table data blocks according to the storage address of the target table and the target table name. 2.根据权利要求1所述的一种数据库表的复制方法,其特征在于,步骤S2包括:2. The method for replicating a database table according to claim 1, wherein step S2 comprises: S21:一次性复制所述所有表数据块,并将所述所有表数据块存储至目标表的存储区域;或者,S21: Copy all the table data blocks at one time, and store all the table data blocks in the storage area of the target table; or, S22:采用可增量同步复制的方法复制所述所有表数据块,并将所述所有表数据块存储至目标表的存储区域。S22: Copy all the table data blocks by using the incremental synchronous replication method, and store all the table data blocks in the storage area of the target table. 3.根据权利要求2所述的一种数据库表的复制方法,其特征在于,步骤S21包括:3. The method for replicating a database table according to claim 2, wherein step S21 comprises: S211:根据所获取的表复制命令create table XX copy from YY获取源表结构,并创建目标表;S211: Obtain the source table structure according to the obtained table copy command create table XX copy from YY, and create the target table; S212:根据第一参数所设定的表数据块个数,依次读取并复制源表存储区域中的表数据块,所述第一参数用于设定一次读取复制的表数据块个数。S212: Read and copy the table data blocks in the source table storage area in turn according to the number of table data blocks set by the first parameter, where the first parameter is used to set the number of table data blocks to be read and copied at one time . 4.根据权利要求3所述的一种数据库表的复制方法,其特征在于,所述第一参数设定的一次读取的表数据块个数为64。4 . The method for replicating a database table according to claim 3 , wherein the number of table data blocks read at one time set by the first parameter is 64. 5 . 5.根据权利要求2所述的一种数据库表的复制方法,其特征在于,步骤S22包括:5. The method for replicating a database table according to claim 2, wherein step S22 comprises: S221:根据所获取的表复制命令create table XX integrate copy from YY获取源表结构,并创建目标表;S221: Obtain the source table structure according to the obtained table copy command create table XX integrate copy from YY, and create the target table; S222:根据第一参数所设定的表数据块个数,依次读取并复制源表存储区域中的表数据块;S222: Read and copy the table data blocks in the source table storage area in turn according to the number of table data blocks set by the first parameter; S223:当被读取后的表数据块中的表记录发生变化时,根据第二参数将发生变化的表数据块记录至表数据块变化记录文件中,所述第二参数用于设定表数据块变更记录文件所在的路径及文件名;S223: When the table record in the read table data block changes, record the changed table data block in the table data block change record file according to a second parameter, where the second parameter is used to set the table The path and file name of the data block change record file; S224:根据所获取的表增量同步命令start integrate incr copy,按照时间顺序依次读取所述表数据块变化记录文件中的表数据块,并将所述表数据块变化记录文件中的表数据块依次同步至目标表;S224: According to the obtained table incremental synchronization command start integrate incr copy, sequentially read the table data blocks in the table data block change record file in chronological order, and convert the table data blocks in the table data block change record file The blocks are synchronized to the target table in turn; S225:删除所述表数据块变化记录文件中读取后的表数据块;S225: delete the read table data block in the table data block change record file; S226:返回步骤S223,直到目标表中的表数据块和源表中的表数据块完全一致为止。S226: Return to step S223 until the table data block in the target table is completely consistent with the table data block in the source table. 6.根据权利要求5所述的一种数据库表的复制方法,其特征在于,所述表数据块变化记录文件的存储内容包括:变化的表数据块、表数据块发生变化的时间戳以及变化的表数据块所属的用户和表名,且所述存储内容按照时间顺序进行存储。6. The method for replicating a database table according to claim 5, wherein the storage content of the table data block change record file comprises: the changed table data block, the time stamp of the change in the table data block, and the change The user and table name to which the table data block belongs, and the storage content is stored in chronological order. 7.一种数据库表的复制系统,其特征在于,所述系统包括:7. A system for replicating a database table, wherein the system comprises: 表数据块获取模块,用于获取与源表相匹配的所有表数据块;The table data block obtaining module is used to obtain all table data blocks matching the source table; 复制模块,用于复制所述所有表数据块,并将所述所有表数据块存储至目标表的存储区域;a copying module for copying all the table data blocks and storing the all table data blocks in the storage area of the target table; 更新模块,用于根据所述目标表的存储地址和目标表名,更新所述所有表数据块的块头和表目录。An update module, configured to update the block headers and table directories of all the table data blocks according to the storage address of the target table and the target table name. 8.根据权利要求7所述的一种数据库表的复制系统,其特征在于,所述复制模块包括:第一复制单元或第二复制单元;8. The system for copying a database table according to claim 7, wherein the copying module comprises: a first copying unit or a second copying unit; 所述第一复制单元,用于一次性复制所述所有表数据块,并将所述所有表数据块存储至目标表的存储区域;the first copying unit, configured to copy all the table data blocks at one time, and store the all table data blocks in the storage area of the target table; 所述第二复制单元,用于采用可增量同步复制的方法复制所述所有表数据块,并将所述所有表数据块存储至目标表的存储区域。The second copying unit is configured to copy all the table data blocks by adopting the method of incremental synchronous replication, and store all the table data blocks in the storage area of the target table. 9.根据权利要求8所述的一种数据库表的复制系统,其特征在于,所述第一复制单元包括:9. The replication system of a database table according to claim 8, wherein the first replication unit comprises: 第一目标表创建子单元,用于根据所获取的表复制命令create table XX copy fromYY获取源表结构,并创建目标表;The first target table creation subunit is used to obtain the source table structure according to the obtained table copy command create table XX copy fromYY, and create the target table; 第一读取和复制子单元,用于根据第一参数所设定的表数据块个数,依次读取并复制源表存储区域中的表数据块,所述第一参数用于设定一次读取复制的表数据块个数。The first reading and copying subunit is used to sequentially read and copy the table data blocks in the source table storage area according to the number of table data blocks set by the first parameter, and the first parameter is used to set once Read the number of replicated table data blocks. 10.根据权利要求8所述的一种数据库表的复制系统,其特征在于,所述第二复制单元包括:10. The system for replicating a database table according to claim 8, wherein the second replication unit comprises: 第二目标表创建子单元,用于根据所获取的表复制命令create table XX integratecopy from YY获取源表结构,并创建目标表;The second target table creation subunit is used to obtain the source table structure according to the obtained table copy command create table XX integratecopy from YY, and create the target table; 第二读取和复制子单元,用于根据第一参数所设定的表数据块个数,依次读取并复制源表存储区域中的表数据块;The second reading and copying subunit is used for sequentially reading and copying the table data blocks in the source table storage area according to the number of table data blocks set by the first parameter; 变化记录子单元,用于当被读取后的表数据块中的表记录发生变化时,根据第二参数将发生变化的表数据块记录至表数据块变化记录文件中,所述第二参数用于设定表数据块变更记录文件所在的路径及文件名;The change record subunit is used to record the changed table data block in the table data block change record file according to the second parameter when the table record in the read table data block changes, the second parameter Used to set the path and file name of the table data block change record file; 增量同步子单元,用于根据所获取的表增量同步命令start integrate incr copy,按照时间顺序依次读取所述表数据块变化记录文件中的表数据块,并将所述表数据块变化记录文件中的表数据块同步至目标表;The incremental synchronization subunit is used to sequentially read the table data blocks in the table data block change record file according to the obtained table incremental synchronization command start integrate incr copy, and change the table data blocks The table data blocks in the record file are synchronized to the target table; 清除子单元,用于删除所述表数据块变化记录文件中读取后的表数据块;Clearing the subunit for deleting the table data block read in the table data block change record file; 循环子单元,用于执行表复制命令create table XX integrate copy from YY期间,源表数据块中的表记录再次发生变化,以及执行表增量同步命令start integrate incrcopy期间,已经同步的表数据块再次发生变化时,重新启动变化记录子单元、增量同步子单元以及清除子单元,直到目标表中的表数据块和源表中的表数据块完全一致为止。The loop subunit is used to execute the table copy command create table XX integrate copy from YY, the table records in the source table data block change again, and during the execution of the table incremental synchronization command start integrate incrcopy, the already synchronized table data block again When a change occurs, restart the change record subunit, incremental synchronization subunit, and clear subunit until the table data blocks in the target table and the table data blocks in the source table are exactly the same.
CN201811186579.XA 2018-10-09 2018-10-09 A kind of clone method and system of database table Pending CN109492000A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811186579.XA CN109492000A (en) 2018-10-09 2018-10-09 A kind of clone method and system of database table

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811186579.XA CN109492000A (en) 2018-10-09 2018-10-09 A kind of clone method and system of database table

Publications (1)

Publication Number Publication Date
CN109492000A true CN109492000A (en) 2019-03-19

Family

ID=65689450

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811186579.XA Pending CN109492000A (en) 2018-10-09 2018-10-09 A kind of clone method and system of database table

Country Status (1)

Country Link
CN (1) CN109492000A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110764943A (en) * 2019-10-21 2020-02-07 中国民航信息网络股份有限公司 Data processing method and device for Oracle database
CN112966047A (en) * 2021-03-05 2021-06-15 浪潮云信息技术股份公司 Method for realizing table copying function based on distributed database
CN115757397A (en) * 2022-10-26 2023-03-07 北京奥星贝斯科技有限公司 Data reorganization method and device for database table, medium and computer equipment

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2000013111A1 (en) * 1998-08-31 2000-03-09 Computer Associates Think, Inc. Method and apparatus for fast and comprehensive dbms analysis
CN101419616A (en) * 2008-12-10 2009-04-29 阿里巴巴集团控股有限公司 Data synchronization method and device
CN102081665A (en) * 2008-12-10 2011-06-01 阿里巴巴集团控股有限公司 Data synchronization method and device
CN103246549A (en) * 2012-02-07 2013-08-14 阿里巴巴集团控股有限公司 Method and system for data transfer
CN104750744A (en) * 2013-12-31 2015-07-01 中国移动通信集团河南有限公司 Method and device for synchronizing compressed data on basis of Oracle databases
US20150261838A1 (en) * 2014-03-11 2015-09-17 International Business Machines Corporation Managing replication configuration availability
CN105677903A (en) * 2016-02-05 2016-06-15 华为技术有限公司 Data acquisition method and device as well as computer device
CN106777225A (en) * 2016-12-26 2017-05-31 腾讯科技(深圳)有限公司 The moving method and system of a kind of data
CN107608773A (en) * 2017-08-24 2018-01-19 阿里巴巴集团控股有限公司 task concurrent processing method, device and computing device
CN107870960A (en) * 2017-06-25 2018-04-03 平安科技(深圳)有限公司 Data move system and method

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2000013111A1 (en) * 1998-08-31 2000-03-09 Computer Associates Think, Inc. Method and apparatus for fast and comprehensive dbms analysis
CN101419616A (en) * 2008-12-10 2009-04-29 阿里巴巴集团控股有限公司 Data synchronization method and device
CN102081665A (en) * 2008-12-10 2011-06-01 阿里巴巴集团控股有限公司 Data synchronization method and device
CN103246549A (en) * 2012-02-07 2013-08-14 阿里巴巴集团控股有限公司 Method and system for data transfer
CN104750744A (en) * 2013-12-31 2015-07-01 中国移动通信集团河南有限公司 Method and device for synchronizing compressed data on basis of Oracle databases
US20150261838A1 (en) * 2014-03-11 2015-09-17 International Business Machines Corporation Managing replication configuration availability
CN105677903A (en) * 2016-02-05 2016-06-15 华为技术有限公司 Data acquisition method and device as well as computer device
CN106777225A (en) * 2016-12-26 2017-05-31 腾讯科技(深圳)有限公司 The moving method and system of a kind of data
CN107870960A (en) * 2017-06-25 2018-04-03 平安科技(深圳)有限公司 Data move system and method
CN107608773A (en) * 2017-08-24 2018-01-19 阿里巴巴集团控股有限公司 task concurrent processing method, device and computing device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
MAHANSO: ""(转)oracle数据库之间 表复制方法一(extent 方法)"", 《HTTP://BLOG.ITPUB.NET/12272958/VIEWSPACE-696260/》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110764943A (en) * 2019-10-21 2020-02-07 中国民航信息网络股份有限公司 Data processing method and device for Oracle database
CN110764943B (en) * 2019-10-21 2023-05-05 中国民航信息网络股份有限公司 Data processing method and device of Oracle database
CN112966047A (en) * 2021-03-05 2021-06-15 浪潮云信息技术股份公司 Method for realizing table copying function based on distributed database
CN112966047B (en) * 2021-03-05 2023-01-13 上海沄熹科技有限公司 Method for realizing table copying function based on distributed database
CN115757397A (en) * 2022-10-26 2023-03-07 北京奥星贝斯科技有限公司 Data reorganization method and device for database table, medium and computer equipment
WO2024087777A1 (en) * 2022-10-26 2024-05-02 北京奥星贝斯科技有限公司 Data reorganization method and apparatus for database table, medium, and computer device

Similar Documents

Publication Publication Date Title
CN104657382B (en) Method and apparatus for MySQL principal and subordinate's server data consistency detections
CN110209728A (en) A kind of Distributed Heterogeneous Database synchronous method, electronic equipment and storage medium
CN103595797B (en) Caching method for distributed storage system
US20120203745A1 (en) System and method for range search over distributive storage systems
CN110447021A (en) Method, apparatus and system for maintaining metadata and data consistency between data centers
CN102541757A (en) Write cache method, cache synchronization method and device
CN114297289A (en) Incremental data acquisition method and device based on optimized trigger
CN117033398B (en) Data flashback query method and device based on dolt database
CN102799679A (en) Hadoop-based massive spatial data indexing updating system and method
WO2021238341A1 (en) Method and device for updating data in database, and electronic device
CN113672556A (en) Method and device for migrating batch files
CN113190281B (en) ROWID interval-based initialization loading method and device
CN115994148B (en) Multi-table data updating method and device, electronic equipment and readable storage medium
CN107479881B (en) Synchronization method, storage medium, electronic device and system for difference code
CN109684327B (en) Data acquisition method for external link of database
US20260017250A1 (en) Data table processing method and apparatus, computer device, and readable storage medium
CN111078709A (en) Incremental zipper implementation method based on non-updating mode of multi-bin tool HIVE
CN111722962A (en) A storage system and method for CDP data
CN114595224A (en) Data storage method and device and data query method and device
CN112988916A (en) Full and incremental synchronization method, device and storage medium for Clickhouse
CN116842244A (en) Search engine data synchronization method, system, device and storage medium
CN114564445A (en) Method and system suitable for Hive data warehouse to write and update data
CN114036226A (en) Data synchronization method, device, equipment and storage medium
CN120849459B (en) Version-based dynamic quick flashback query method in database
CN117743459A (en) Incremental data synchronization method, device, system, electronic equipment and readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20190319