JP2017027349A - Replication program - Google Patents

Replication program Download PDF

Info

Publication number
JP2017027349A
JP2017027349A JP2015144903A JP2015144903A JP2017027349A JP 2017027349 A JP2017027349 A JP 2017027349A JP 2015144903 A JP2015144903 A JP 2015144903A JP 2015144903 A JP2015144903 A JP 2015144903A JP 2017027349 A JP2017027349 A JP 2017027349A
Authority
JP
Japan
Prior art keywords
database
character string
replication
conversion
instruction
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
JP2015144903A
Other languages
Japanese (ja)
Inventor
克己 松浦
Katsumi Matsuura
克己 松浦
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.)
Exa Corp
Original Assignee
Exa Corp
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 Exa Corp filed Critical Exa Corp
Priority to JP2015144903A priority Critical patent/JP2017027349A/en
Publication of JP2017027349A publication Critical patent/JP2017027349A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

PROBLEM TO BE SOLVED: To suppress data mismatch due to difference of handling of a specific character before and after replicating of a database.SOLUTION: A replication program of the invention is configured to convert zero byte length characters string and a null value on a replication source database, according to handling of the character strings on the replication source database.SELECTED DRAWING: Figure 1

Description

本発明は、データベースのレプリケーションに関する。   The present invention relates to database replication.

データベースのレプリケーションは、あるデータベースと全く同じ内容の複製データベースを作成する処理であり、いわゆるバックアップとは区別される。レプリケーションを利用することにより、例えばマスタデータベースの内容をスレーブデータベースに反映することができる。この手法はデータベースを冗長構成にするとき用いられる。   Database replication is a process of creating a duplicate database having exactly the same contents as a certain database, and is distinguished from so-called backup. By using replication, for example, the contents of the master database can be reflected in the slave database. This technique is used when making a database redundant.

レプリケーションを実施する毎にデータベースの全内容を複製すると、処理負荷や通信負荷の観点から多大なリソースが必要となる。そこで現実的な手法として、マスタデータベースに対する更新部分のみを抽出してこれをスレーブデータベースに反映することが考えられる。   If the entire contents of the database are replicated every time replication is performed, a large amount of resources are required from the viewpoint of processing load and communication load. Therefore, as a practical method, it is conceivable to extract only the updated portion of the master database and reflect this in the slave database.

下記特許文献1は、データベースシステムのレプリケーションに関する技術を記載している。同文献においては、トランザクションレプリケーションのためのデータ変更を追跡するアルゴリズムとして、ログベースのものとトリガベースのものが例示されている(同文献の0007〜0008参照)。   The following Patent Document 1 describes a technique related to database system replication. In this document, a log-based algorithm and a trigger-based algorithm are exemplified as an algorithm for tracking data changes for transaction replication (see 0007 to 0008 in the same document).

特開2005−301329号公報JP 2005-301329 A

データベースレプリケーションは、異なる機種のホストコンピュータ間で実施される場合がある。ホストコンピュータの機種によっては、データベース内で使用する特定文字の取り扱い方が異なる場合がある。さらには同機種のホストコンピュータであっても、データベース管理システム(DBMS)によって特定文字の取り扱い方が異なる場合もあり得る。レプリケート先データベースにおいて特定文字が正しく取り扱われなかった場合、レコードの内容が正しく認識されず、したがってレプリケート前後に係る整合性がとれなくなる可能性がある。   Database replication may be performed between different types of host computers. Depending on the model of the host computer, the handling of specific characters used in the database may differ. Furthermore, even a host computer of the same model may have different handling of specific characters depending on the database management system (DBMS). If the specific character is not handled correctly in the replication destination database, the contents of the record are not correctly recognized, and therefore there is a possibility that consistency before and after the replication cannot be achieved.

上記特許文献1記載の技術においては、トランザクションの整合性をレプリケート後においても維持することに着目しており、異機種間(または異なるDBMS間)でデータベースをレプリケートすることに起因する問題については考慮されていない。しかし実際の運用場面においては、例えばオープンプラットフォーム(Windows(登録商標)など)上のDBMSから汎用機上のDBMSへレプリケーションを実施する場合があり、したがってレプリケート前後それぞれのプラットフォームにおける特定文字の取り扱いが異なる可能性がある。かかる場合においてもデータベースの整合性を維持することのできる技術が求められる。   The technique described in Patent Document 1 focuses on maintaining transaction consistency even after replication, and considers problems caused by replicating databases between different models (or between different DBMSs). It has not been. However, in actual operation situations, for example, replication may be performed from a DBMS on an open platform (Windows (registered trademark), etc.) to a DBMS on a general-purpose machine, and therefore the handling of specific characters on each platform before and after replication is different there is a possibility. Even in such a case, a technique capable of maintaining the consistency of the database is required.

本発明は、上記のような課題に鑑みてなされたものであり、データベースのレプリケート前後に係る特定文字の取り扱いが異なることに起因するデータ不整合を抑制することを目的とする。   The present invention has been made in view of the above-described problems, and an object of the present invention is to suppress data mismatch caused by different handling of specific characters before and after database replication.

本発明に係るレプリケーションプログラムは、レプリケート元データベースにおけるゼロバイト長文字列およびnull値を、レプリケート先データベースにおけるこれら文字列の取り扱いに応じて変換する。   The replication program according to the present invention converts a zero-byte length character string and a null value in the replication source database according to the handling of these character strings in the replication destination database.

本発明に係るレプリケーションプログラムによれば、データベース管理システム毎のゼロバイト長文字列およびnull値の取り扱いの違いを吸収してレプリケーションを正しく実行することができる。   According to the replication program of the present invention, it is possible to correctly perform replication by absorbing differences in handling of a zero-byte length character string and a null value for each database management system.

実施形態1に係るレプリケーションプログラム120を実行するレプリケーションコンピュータ100およびその周辺構成を示す図である。1 is a diagram showing a replication computer 100 that executes a replication program 120 according to Embodiment 1 and its peripheral configuration. FIG. 変換テーブル140の構成とデータ例を示す図である。It is a figure which shows the structure and data example of a conversion table. 履歴テーブル230の構成とデータ例を示す図である。It is a figure which shows the structure and data example of the log | history table 230. FIG. レプリケーションプログラム120の動作を説明する図である。FIG. 6 is a diagram for explaining the operation of a replication program 120. 実施形態2における変換テーブル140の構成とデータ例を示す図である。It is a figure which shows the structure and example of a data of the conversion table 140 in Embodiment 2. FIG. 実施形態3における変換テーブル140の構成とデータ例を示す図である。It is a figure which shows the structure and data example of the conversion table 140 in Embodiment 3. FIG.

<実施の形態1>
図1は、本発明の実施形態1に係るレプリケーションプログラム120を実行するレプリケーションコンピュータ100およびその周辺構成を示す図である。レプリケーションコンピュータ100は、第1DB(DataBase)220を第2DB320へレプリケートするコンピュータであり、CPU(Central Processing Unit)110、レプリケーションプログラム120、記憶装置130を備える。
<Embodiment 1>
FIG. 1 is a diagram showing a replication computer 100 that executes a replication program 120 according to the first embodiment of the present invention and its peripheral configuration. The replication computer 100 is a computer that replicates a first DB (DataBase) 220 to a second DB 320, and includes a CPU (Central Processing Unit) 110, a replication program 120, and a storage device 130.

CPU110は、レプリケーションプログラム120を実行する。レプリケーションプログラム120は、データベースをレプリケートする処理を実装したプログラムである。以下では記載の便宜上、レプリケーションプログラム120を動作主体として説明する場合があるが、実際にこれを実行するのはCPU110であることを付言しておく。   The CPU 110 executes the replication program 120. The replication program 120 is a program that implements a process of replicating a database. In the following, for convenience of description, the replication program 120 may be described as an operation subject. However, it is added that the CPU 110 actually executes this.

記憶装置130は、変換テーブル140を格納している。変換テーブル140は、レプリケーションプログラム120がレプリケーションを実施する際に、レプリケート元データベース上における特定文字をレプリケート先データベース上における書式に変換するルールを定義している。変換テーブル140の具体例については後述する。   The storage device 130 stores a conversion table 140. The conversion table 140 defines a rule for converting a specific character on the replication source database into a format on the replication destination database when the replication program 120 performs replication. A specific example of the conversion table 140 will be described later.

第1DBコンピュータ210は、第1DB220を実装した第1データベース管理システム(図示せず)を実行するコンピュータである。第1DBコンピュータ210は、第1DB220に対する更新操作を履歴テーブル230に格納する。履歴テーブル230の具体例については後述する。第1DBコンピュータ210はさらに、更新操作を履歴テーブル230へ格納する際に、採番データ240を用いる。採番データ240については後述する。   The first DB computer 210 is a computer that executes a first database management system (not shown) that implements the first DB 220. The first DB computer 210 stores an update operation for the first DB 220 in the history table 230. A specific example of the history table 230 will be described later. The first DB computer 210 further uses the numbering data 240 when storing the update operation in the history table 230. The numbering data 240 will be described later.

第2DBコンピュータ310は、第1データベース管理システムとは異なる第2データベース管理システムを実行するコンピュータである。第2データベース管理システムは、第2DB320を実装している。   The second DB computer 310 is a computer that executes a second database management system different from the first database management system. The second database management system has a second DB 320 mounted.

<実施の形態1:データベース管理システムについて>
データベース管理システムについて以下に補足する。データベースは単なるデータファイルの集合体ではなく、例えば(a)トランザクションを受け付けて実行する、(b)トランザクションのログを記録する、(c)所定のイベントが発生するとあらかじめ定めておいた処理を実行する(トリガ機能)、などの機能を有する。これら機能を実装したプログラムのことを一般にデータベース管理システムと呼ぶ。これら機能をどのように実装するかは個々のデータベース管理システムに依拠する。したがってデータベース管理システム毎に機能仕様が異なる場合がある。
<Embodiment 1: About database management system>
The database management system is supplemented below. The database is not simply a collection of data files. For example, (a) a transaction is accepted and executed, (b) a transaction log is recorded, and (c) a predetermined process is executed when a predetermined event occurs. (Trigger function). A program that implements these functions is generally called a database management system. How these functions are implemented depends on the individual database management system. Therefore, the function specifications may be different for each database management system.

データベースが保持するレコードは、それぞれデータ型を有している。例えば文字列レコードを保持するレコードまたはカラムは固定長文字列型/可変長文字列型などの文字列型を有し、数値レコードを保持するレコードまたはカラムは整数型/浮動小数点型などの数値型を有する。   Each record held in the database has a data type. For example, a record or column that holds a character string record has a character string type such as a fixed-length character string type / variable-length character string type, and a record or column that holds a numeric record is a numeric type such as an integer type or a floating-point type Have

データベース管理システムによっては、データ型の取り扱い方が異なる場合がある。例えば可変長文字列型のカラムにゼロバイト長文字列“”を格納した場合、あるデータベース管理システムにおいてはこれをその定義通りゼロバイト長文字列“”として格納するのに対し、別のデータベース管理システムにおいてはこれをnull値(データなしを示す特殊なビット値)として格納することが、実際に発生している。   Some database management systems may handle data types differently. For example, when a zero-byte length character string “” is stored in a variable-length character string type column, it is stored as a zero-byte length character string “” as defined in one database management system, whereas another database management. In the system, storing this as a null value (a special bit value indicating no data) has actually occurred.

一般にゼロバイト長文字列とnull値は、アプリケーション上における取り扱いが全く異なる。例えばゼロバイト長文字列は文字列として取り扱われるのに対し、null値は無効なデータ値として取り扱われる場合がある。そうすると、例えば第1DB220が格納しているレコードおよびそのレコードを読み書きするアプリケーションを第2DBコンピュータ310へ移行(第1DB220については第2DB320へレプリケート)した場合、アプリケーションが正しく動作しない可能性がある。例えば当該アプリケーションが第1DB220上のゼロバイト長文字列を文字列変数として処理していた場合、当該アプリケーションは第2DB320上の同じレコードを文字列として処理することができない可能性がある。具体的には、ゼロバイト長文字列に対して文字列を追加する処理が、無効なデータ値に対する処理として正常に動作しない可能性がある。   In general, a zero-byte length character string and a null value are completely different on the application. For example, a zero-byte character string may be handled as a character string, while a null value may be handled as an invalid data value. Then, for example, when the record stored in the first DB 220 and the application that reads and writes the record are migrated to the second DB computer 310 (the first DB 220 is replicated to the second DB 320), the application may not operate correctly. For example, when the application is processing a zero byte length character string on the first DB 220 as a character string variable, the application may not be able to process the same record on the second DB 320 as a character string. Specifically, the process of adding a character string to a zero-byte length character string may not operate normally as a process for an invalid data value.

そこで本発明においては、異なるデータベース管理システム間のレプリケーションにともなう上記のような不具合を解消するため、取り扱い方がデータベース管理システム間で異なるデータについてかかる不具合が生じないような処理を施すこととした。   Therefore, in the present invention, in order to eliminate the above-mentioned problems associated with replication between different database management systems, processing is performed so that such problems do not occur for data that is handled differently between database management systems.

<実施の形態1:テーブル構成>
図2は、変換テーブル140の構成とデータ例を示す図である。変換テーブル140はレプリケート前後におけるデータ変換ルールを定義するデータテーブルである。変換テーブル140は、テーブル名フィールド141、カラム名フィールド142、ゼロバイト長文字列変換ルールフィールド143、null値変換ルールフィールド144を有する。
<Embodiment 1: Table configuration>
FIG. 2 is a diagram illustrating the configuration of the conversion table 140 and data examples. The conversion table 140 is a data table that defines data conversion rules before and after replication. The conversion table 140 includes a table name field 141, a column name field 142, a zero-byte length character string conversion rule field 143, and a null value conversion rule field 144.

テーブル名フィールド141とカラム名フィールド142は、レプリケート元データベースのテーブル名とカラム名を一意に識別する文字列である。レプリケート元データベースが複数のデータベースを構築している場合は、さらにデータベース名を指定することもできる。ゼロバイト長文字列変換ルールフィールド143は、レプリケート元データベース上においてゼロバイト長文字列のカラム値が格納されている場合、その値をレプリケート先データベースにおいてどのような値として格納するかを指定する書式を示す。null値変換ルールフィールド144は、レプリケート元データベース上においてnull値のカラム値が格納されている場合、その値をレプリケート先データベースにおいてどのような値として格納するかを指定する書式を示す。   The table name field 141 and the column name field 142 are character strings that uniquely identify the table name and column name of the replication source database. If the source database has multiple databases, you can also specify the database name. The zero byte length character string conversion rule field 143 is a format for specifying what value is stored in the replication destination database when the column value of the zero byte length character string is stored in the replication source database. Indicates. The null value conversion rule field 144 indicates a format for designating what value is stored in the replicate destination database when the null value column value is stored in the replicate source database.

図2に示す1行目のデータ例においては、レプリケート元データベースの“table1”テーブルの“column1”カラムがゼロバイト長文字列を格納している場合、レプリケート先においてはこれをスペース文字に置き換えるべき旨を定義している。同様に同カラムがnull値を格納している場合、レプリケート先においてもこれをnull値として格納すべき旨を定義している。変換ルールが定義されていないカラムについては格別変換を実施せずそのままレプリケートすればよい。   In the data example of the first row shown in FIG. 2, when the “column1” column of the “table1” table of the replication source database stores a zero-byte length character string, it should be replaced with a space character at the replication destination. Is defined. Similarly, when a null value is stored in the same column, it is defined that this should be stored as a null value at the replicate destination. Columns for which no conversion rule is defined may be replicated as they are without performing special conversion.

図3は、履歴テーブル230の構成とデータ例を示す図である。履歴テーブル230は、第1DB220に対する更新操作を記録するデータテーブルである。履歴テーブル230は、順序フィールド231、状態フィールド232、命令文フィールド233を有する。   FIG. 3 is a diagram illustrating a configuration of the history table 230 and an example of data. The history table 230 is a data table that records update operations for the first DB 220. The history table 230 has an order field 231, a status field 232, and a command statement field 233.

順序フィールド231は、第1DB220に対して更新処理が実施された通番を保持する。状態フィールド232は、当該レコードを第2DB320に対して反映済みか否かを示す。命令文フィールド233は、レプリケート元データベースに対して実施された更新操作の命令文を示す。ここでいう更新操作は、例えばSQLにおけるUPDATE命令に限られず、INSERT命令やDELETE命令を含む、データベースに対する全ての書き込み操作を含むものである。   The order field 231 holds a serial number for which update processing has been performed on the first DB 220. The status field 232 indicates whether or not the record has been reflected on the second DB 320. The command statement field 233 indicates the command statement of the update operation performed on the replication source database. The update operation here is not limited to the UPDATE instruction in SQL, for example, but includes all write operations to the database including the INSERT instruction and the DELETE instruction.

履歴テーブル230はさらに、記録した更新操作における各カラムに対する指定値を保持するためのフィールドを有する。例えばINSERT命令であれば各カラムに対して格納した値を保持するためのフィールドを有し、DELETE命令であれば削除するレコードを特定するための条件文におけるカラム値を保持するためのフィールドを有する。各テーブルが有するフィールドはテーブル毎に異なるので、レプリケート元データベースが有するテーブル毎に履歴テーブル230を設ける。例えば第1DB220のあるテーブルが2つのカラムを有する場合、図3に示すようにその2つのカラムに対する操作を記録するフィールドを設けることができる。   The history table 230 further has a field for holding a specified value for each column in the recorded update operation. For example, an INSERT instruction has a field for holding a value stored for each column, and a DELETE instruction has a field for holding a column value in a conditional statement for specifying a record to be deleted. . Since the fields of each table are different for each table, a history table 230 is provided for each table of the replication source database. For example, when a table in the first DB 220 has two columns, a field for recording operations for the two columns can be provided as shown in FIG.

データベースに対する更新操作は、複数のテーブルにまたがって実施される場合がしばしばある。またあるテーブルに対する更新操作は別のテーブルのレコードを参照しながら実施される場合がある。テーブル間の整合性を維持しつつこれら複数のテーブルにまたがって更新操作を実施するためには、更新操作を実施する順序が重要になる。そこで本実施形態1においては、レプリケート元データベース(ここでは第1DB220)に対して更新操作を実施した順序を、順序フィールド231に記録することとした。   Update operations on the database are often performed across multiple tables. An update operation for a certain table may be performed with reference to a record in another table. In order to perform the update operation across the plurality of tables while maintaining the consistency between the tables, the order in which the update operations are performed becomes important. Therefore, in the first embodiment, the order in which the update operation is performed on the replication source database (here, the first DB 220) is recorded in the order field 231.

レプリケート元データベースに対する更新操作が発生したことを検出する手段としては例えば更新操作を契機として起動されるトリガをレプリケート元データベースにおいて実装しておけばよい。多くのデータベース管理システムはトリガ機構を備えているので、これを実装するのは容易である。   As a means for detecting the occurrence of an update operation for the replication source database, for example, a trigger that is activated when the update operation is performed may be implemented in the replication source database. Many database management systems are equipped with a trigger mechanism, which is easy to implement.

採番データ240は、順序フィールド231の現在値を保持する。各トリガの開始部分において採番データ240を参照して現在値を取得し、更新操作を履歴テーブル230に対して記録した後に採番データ240の現在値を1つインクリメントすることにより、各更新操作の実施順序を記録することができる。また複数のテーブルにまたがった更新操作であっても、各更新操作を記録する際に参照する現在値を採番データ240に集約することにより、テーブルをまたがる更新処理を実施すべき順序を保存してレプリケート後においても整合性を維持することができる。   The numbering data 240 holds the current value of the order field 231. Each update operation is obtained by referring to the numbering data 240 at the start of each trigger, acquiring the current value, recording the update operation in the history table 230, and then incrementing the current value of the numbering data 240 by one. Can be recorded. In addition, even in the case of an update operation extending over a plurality of tables, the current value to be referred to when recording each update operation is aggregated into the numbering data 240, so that the order in which the update process across the tables should be performed is saved. Thus, consistency can be maintained even after replication.

図4は、レプリケーションプログラム120の動作を説明する図である。以下図4の各ステップについて説明する。   FIG. 4 is a diagram for explaining the operation of the replication program 120. Hereinafter, each step of FIG. 4 will be described.

(図4:ステップ(1):未転送の履歴レコードを抽出)
レプリケーションプログラム120は、履歴テーブル230が格納しているレコードのうち、状態フィールド232が“未転送”であるものを抽出する。複数の履歴テーブル230が存在する場合(すなわちレプリケート元テーブルが複数存在する場合)は、全ての履歴テーブル230からレコードを抽出する。抽出したレコードを順序フィールド231にしたがって本ステップ内でソートしてもよいし、後のステップにおいてソートしてもよい。ここでは本ステップにおいてソートするものとする。
(Figure 4: Step (1): Extract untransferred history records)
The replication program 120 extracts records whose status field 232 is “untransferred” from the records stored in the history table 230. When there are a plurality of history tables 230 (that is, when there are a plurality of replication source tables), records are extracted from all the history tables 230. The extracted records may be sorted in this step according to the order field 231 or may be sorted in a later step. Here, it is assumed that sorting is performed in this step.

(図4:ステップ(2):変換ルールを適用)
レプリケーションプログラム120は、ステップ(1)において抽出したレコードに対して変換テーブル140が定義している変換ルールを適用することにより、ゼロバイト長文字列とnull値をそれぞれレプリケート先データベース(ここでは第2DB320)上における書式に変換する。例えば図3の3行目のレコードはカラム1をゼロバイト長文字列“”に更新する旨を指定しているので、これを第2DB320へ反映する際には、図2の1行目の変換ルールにしたがって、当該レコードの“”を“ ”(スペース文字)に変換する。
(Figure 4: Step (2): Applying conversion rules)
The replication program 120 applies the conversion rule defined by the conversion table 140 to the record extracted in step (1), thereby each of the zero byte length character string and the null value is replicated to the destination database (here, the second DB 320). ) Convert to the above format. For example, since the record in the third line in FIG. 3 specifies that column 1 is updated to the zero-byte character string “”, when this is reflected in the second DB 320, the conversion in the first line in FIG. According to the rules, “” of the record is converted to “” (space character).

(図4:ステップ(3):第2DBを更新:その1)
レプリケーションプログラム120は、ステップ(2)においてゼロバイト長文字列とnull値を変換した後の各レコードを用いて、第2DB320を更新する命令を生成する。第2DB320に対して実施すべき更新命令の種別は、命令文フィールド233に記載されている。当該更新命令において指定すべき各カラム値は、各履歴テーブル230それぞれのカラム値部分(変換を実施した場合はその変換後の値)に記載されている。したがってレプリケーションプログラム120は、これらフィールドを参照することにより、第2DB320に対して実施すべき更新命令を生成することができる。
(FIG. 4: Step (3): Update the second DB: Part 1)
The replication program 120 generates an instruction to update the second DB 320 using each record after converting the zero-byte length character string and the null value in step (2). The type of update command to be executed for the second DB 320 is described in the command statement field 233. Each column value to be specified in the update command is described in a column value portion of each history table 230 (or a value after conversion when conversion is performed). Therefore, the replication program 120 can generate an update command to be executed on the second DB 320 by referring to these fields.

(図4:ステップ(3):第2DBを更新:その2)
レプリケーションプログラム120は、生成した更新命令を順序フィールド231が指定する順番で実行することにより、第2DB320に対して履歴テーブル230の内容を反映する。レプリケーションプログラム120は、反映したレコードについては、状態フィールド232を“転送済”に変更する。
(FIG. 4: Step (3): Update the second DB: Part 2)
The replication program 120 reflects the contents of the history table 230 on the second DB 320 by executing the generated update instructions in the order specified by the order field 231. The replication program 120 changes the status field 232 to “transferred” for the reflected record.

(図4:ステップ(2)〜(3):補足)
これらステップを実施する順序は入れ替えてもよい。すなわち、第2DB320に対する更新命令を生成した後に変換ルールを適用してもよい。
(FIG. 4: Steps (2) to (3): Supplement)
The order in which these steps are performed may be switched. That is, the conversion rule may be applied after generating an update command for the second DB 320.

<実施の形態1:まとめ>
本実施形態1に係るレプリケーションプログラム120は、第1DB220におけるゼロバイト長文字列とnull値を第2DB320における書式にそれぞれ変換した上で、第1DB220のレコードを第2DB320へレプリケートする。これにより、レプリケート後においてもデータ不整合を生じることなくアプリケーションを稼働させることができる。
<Embodiment 1: Summary>
The replication program 120 according to the first embodiment converts the zero-byte length character string and the null value in the first DB 220 into the format in the second DB 320, and then replicates the record in the first DB 220 to the second DB 320. As a result, the application can be operated without data inconsistency even after replication.

本実施形態1に係るレプリケーションプログラム120は、第2DB320におけるゼロバイト長文字列の書式とnull値の書式を、カラム毎に変換する。これにより、変換を実施すべきカラムについてのみ変換を実施し、レプリケーションの処理効率を高めることができる。またテーブルのカラム構造に依拠することなく上記変換を実施することができる。   The replication program 120 according to the first embodiment converts the format of the zero byte length character string and the format of the null value in the second DB 320 for each column. As a result, the conversion can be performed only for the column to be converted, and the replication processing efficiency can be improved. Further, the above conversion can be performed without depending on the column structure of the table.

<実施の形態2>
図5は、本発明の実施形態2における変換テーブル140の構成とデータ例を示す図である。本実施形態2において、変換テーブル140は実施形態1で説明した構成に加えて新たに抽出フォーマットフィールド145を有する。その他構成は実施形態1と同様である。
<Embodiment 2>
FIG. 5 is a diagram illustrating a configuration and data example of the conversion table 140 according to the second embodiment of the present invention. In the second embodiment, the conversion table 140 has a new extraction format field 145 in addition to the configuration described in the first embodiment. Other configurations are the same as those of the first embodiment.

抽出フォーマットフィールド145は、レプリケート元データベースのレコードを抽出する際に当該レコードをどのようなデータ型として取り扱うかを指定する。例えば“TEXT”は元レコードを文字列型として取り扱うことを示し、“FLOAT3.2”は整数部3桁かつ小数部2ケタの浮動小数点型として取り扱うことを示す。   The extraction format field 145 specifies what data type the record is handled when extracting the record of the replication source database. For example, “TEXT” indicates that the original record is handled as a character string type, and “FLOAT3.2” indicates that it is handled as a floating-point type having a 3-digit integer part and 2-digit decimal part.

レプリケーションプログラム120は、レプリケート元レコードを抽出する際に、抽出フォーマットフィールド145が指定するデータ型に合致しない部分については適宜切り捨てなどの措置を施す。例えば“FLOAT3.2”が指定されている抽出元カラムの小数部が3桁以上ある場合、3桁目以降は切り捨てまたは四捨五入する。あるいは“FLOAT3.2”が指定されている抽出元カラムが数値でない場合、抽出後のカラム値は例えば“0.0”とする。   When the replication program 120 extracts the replication source record, the replication program 120 takes measures such as truncating the portion that does not match the data type specified by the extraction format field 145 as appropriate. For example, if the extraction source column for which “FLOAT3.2” is specified has three or more decimal parts, the third and subsequent digits are rounded down or rounded off. Alternatively, when the extraction source column for which “FLOAT3.2” is designated is not a numerical value, the column value after extraction is set to “0.0”, for example.

<実施の形態3>
実施形態1においては、第1DB220から第2DB320へレプリケートを実施することを前提としたが、第2DB320から第1DB220へレプリケートを実施する際にも本発明を用いることができる。本発明の実施形態3ではその1例について説明する。
<Embodiment 3>
In the first embodiment, it is assumed that replication is performed from the first DB 220 to the second DB 320. However, the present invention can also be used when performing replication from the second DB 320 to the first DB 220. In the third embodiment of the present invention, an example will be described.

第2DB320から第1DB220へレプリケートを実施する際にも、処理対象とするデータベースが入れ替わったのみであるから、実施形態1と同様の処理手順を用いることができる。ただし第2DB320がゼロバイト長文字列をnull値として取り扱うことに鑑み、レプリケーションプログラム120またはマニュアル作業によってゼロバイト長文字列の代わりにスペースを代入する措置があらかじめ取られ、レプリケート元たる第2DB320がかかるレコードを格納している場合がある。そこで本実施形態3においては、レプリケート元レコードがスペース文字列であった場合にこれをレプリケート先においてどのように取り扱うかをあらかじめ定義することとした。   Even when the replication is performed from the second DB 320 to the first DB 220, the processing procedure similar to that of the first embodiment can be used because only the database to be processed is replaced. However, in view of the fact that the second DB 320 handles the zero byte length character string as a null value, a measure for substituting a space instead of the zero byte length character string is taken in advance by the replication program 120 or manual operation, and the second DB 320 that is the replication source is applied. May contain records. Therefore, in the third embodiment, when the replication source record is a space character string, how to handle it at the replication destination is defined in advance.

図6は、本実施形態3における変換テーブル140の構成とデータ例を示す図である。本実施形態3において、変換テーブル140は実施形態1で説明した構成に加えて新たにスペース変換ルールフィールド146を有する。その他構成は実施形態1と同様である。   FIG. 6 is a diagram illustrating a configuration and data example of the conversion table 140 according to the third embodiment. In the third embodiment, the conversion table 140 has a space conversion rule field 146 in addition to the configuration described in the first embodiment. Other configurations are the same as those of the first embodiment.

スペース変換ルールフィールド146は、レプリケート元データベース上においてスペース文字列のカラム値が格納されている場合、その値をレプリケート先データベースにおいてどのような値として格納するかを指定する書式を示す。上記想定によればスペース文字列はレプリケート先データベースにおいてゼロバイト長文字列として格納すべきであるから、図6の1行目のレコードはその旨を指定している。ただしカラムの性質によってはスペースを格納することが初めから意図されている場合もあるので、そのようなカラムについては本フィールドを指定せずレプリケート元レコードをそのままレプリケートするようにしてもよい。図6の2行目のレコードはその旨を示す。   The space conversion rule field 146 indicates a format for designating what value is stored in the replication destination database when the column value of the space character string is stored in the replication source database. According to the above assumption, the space character string should be stored as a zero-byte length character string in the replication destination database, so the record on the first line in FIG. 6 specifies that fact. However, there is a case where it is originally intended to store a space depending on the property of the column. For such a column, this field may not be specified and the replication source record may be replicated as it is. The record on the second line in FIG. 6 indicates that.

<本発明の変形例について>
本発明は上記した実施例に限定されるものではなく、様々な変形例が含まれる。例えば、上記した実施例は本発明を分かりやすく説明するために詳細に説明したものであり、必ずしも説明した全ての構成を備えるものに限定されるものではない。また、ある実施例の構成の一部を他の実施例の構成に置き換える事が可能であり、また、ある実施例の構成に他の実施例の構成を加えることも可能である。また、各実施例の構成の一部について他の構成の追加・削除・置換をすることができる。
<Modification of the present invention>
The present invention is not limited to the above-described embodiments, and includes various modifications. For example, the above-described embodiments have been described in detail for easy understanding of the present invention, and are not necessarily limited to those having all the configurations described. Further, a part of the configuration of a certain embodiment can be replaced with the configuration of another embodiment, and the configuration of another embodiment can be added to the configuration of a certain embodiment. In addition, it is possible to add, delete, and replace other configurations for a part of the configuration of each embodiment.

以上の実施形態において、レプリケーションプログラム120は、レプリケート前後の各DBがそれぞれ異なる文字コードを用いる場合は、レプリケート元レコードをレプリケート先データベースが使用する文字コードへ変換してもよい。   In the above embodiment, the replication program 120 may convert the replication source record into the character code used by the replication destination database when the DBs before and after the replication use different character codes.

以上の実施形態において、ゼロバイト長文字列をスペース文字列に変換する例を示したが、ゼロバイト長文字列がnull値として取り扱われる不具合を回避するためには何らかの文字列が格納されていればよいので、スペース以外の適当な文字列を用いてもよい。ただし処理の便宜に鑑みて、何らかの1バイト長以上の文字または文字列であることが望ましい。   In the above embodiment, an example in which a zero-byte length character string is converted to a space character string has been shown. However, in order to avoid a problem that a zero-byte length character string is handled as a null value, any character string may be stored. Any suitable character string other than a space may be used. However, in view of the convenience of processing, it is desirable that the character or character string has some length of 1 byte or more.

以上の実施形態においては、説明の容易のためRDBMS(リレーショナルデータベース管理システム)におけるSQL命令文を例示したが、実施すべき命令はデータベース管理システムの仕様に応じたものを適宜用いればよく、必ずしもSQL命令文に限られるものではない。   In the above embodiment, the SQL statement in the RDBMS (Relational Database Management System) is illustrated for ease of explanation, but the command to be implemented may be appropriately used according to the specification of the database management system, and is not necessarily SQL. It is not limited to imperative sentences.

以上の実施形態においては、履歴テーブル230にレコードを格納する手段としてデータベーストリガを用いているが、その他適当な手段によりレプリケート元データベースに対する更新操作を記録してもよい。   In the above embodiment, the database trigger is used as means for storing records in the history table 230, but the update operation for the replication source database may be recorded by other appropriate means.

以上の実施形態においては、第1DBコンピュータ210上のデータベースを第2DBコンピュータ310上のデータベースへレプリケートしているが、同一コンピュータ上の異なるデータベース管理システム間でレプリケーションを実施する際に本発明を用いることもできる。   In the above embodiment, the database on the first DB computer 210 is replicated to the database on the second DB computer 310, but the present invention is used when performing replication between different database management systems on the same computer. You can also.

100:レプリケーションコンピュータ、110:CPU、120:レプリケーションプログラム、130:記憶装置、140:変換テーブル、210:第1DBコンピュータ、220:第1DB、230:履歴テーブル、240:採番データ、310:第2DBコンピュータ、320:第2DB。   100: Replication computer, 110: CPU, 120: Replication program, 130: Storage device, 140: Conversion table, 210: First DB computer, 220: First DB, 230: History table, 240: Numbering data, 310: Second DB Computer, 320: second DB.

Claims (5)

第1データベースが保持しているレコードを、前記第1データベースとは異なるデータベース管理システムを用いて実装された第2データベースが保持するレコードとして複製する処理を、コンピュータに実行させるレプリケーションプログラムであって、前記コンピュータに、
前記第1データベースを更新する第1命令の実行履歴を記述した履歴データを取得するステップ、
前記第2データベース上におけるゼロバイト長文字列の書式および前記第2データベース上におけるnull値の書式を定義する変換テーブルを読み取るステップ、
前記第1命令と同じレコード操作を実施する処理を前記第2データベースに対して実行する第2命令を生成するステップ、
前記第2命令のうちゼロバイト長文字列を用いる部分を前記変換テーブルの定義にしたがって前記第2データベース上における書式に変換するとともに、前記第2命令のうちnull値を用いる部分を前記変換テーブルの定義にしたがって前記第2データベース上における書式に変換する、変換ステップ、
前記変換ステップによって変換した前記第2命令を実行することにより前記第2データベースを更新するステップ、
を実行させることを特徴とするレプリケーションプログラム。
A replication program that causes a computer to execute a process of replicating a record held by a first database as a record held by a second database implemented using a database management system different from the first database, In the computer,
Obtaining history data describing an execution history of a first instruction for updating the first database;
Reading a conversion table defining a format of a zero byte length string on the second database and a format of null values on the second database;
Generating a second instruction for executing a process for performing the same record operation as the first instruction on the second database;
The part using the zero byte length character string of the second instruction is converted into the format on the second database according to the definition of the conversion table, and the part using the null value of the second instruction is converted into the conversion table. Converting to a format on the second database according to the definition;
Updating the second database by executing the second instruction converted by the converting step;
A replication program characterized by executing
前記第1データベースおよび前記第2データベースは、リレーショナル形式のデータベースであり、
前記変換テーブルは、前記第1データベースが有するテーブルのカラムごとに前記ゼロバイト長文字列の書式および前記null値の書式を定義しており、
前記変換ステップにおいては、前記コンピュータに、
前記変換テーブルの定義にしたがって、前記第2命令のうち前記第1データベースが有するテーブルのカラムに対応する部分毎に、前記変換を実施させる
ことを特徴とする請求項1記載のレプリケーションプログラム。
The first database and the second database are relational databases,
The conversion table defines the format of the zero byte length character string and the format of the null value for each column of the table of the first database,
In the conversion step, the computer
2. The replication program according to claim 1, wherein the conversion is performed for each portion corresponding to a column of a table included in the first database in the second instruction according to the definition of the conversion table. 3.
前記レプリケーションプログラムはさらに、前記コンピュータに、
前記第2命令の文字コードを、前記第1データベースが使用する文字コードから前記第2データベースが使用する文字コードへ変換するステップを実行させる
ことを特徴とする請求項1記載のレプリケーションプログラム。
The replication program further on the computer,
The replication program according to claim 1, wherein the step of converting the character code of the second instruction from the character code used by the first database to the character code used by the second database is executed.
前記変換テーブルは、前記第1データベース上におけるゼロバイト長文字列を前記第2データベース上における1バイト長以上の代替文字列に変換するよう指定する変換ルールを定義しており、
前記レプリケーションプログラムは、前記変換ステップにおいて前記コンピュータに、前記変換ルールの定義にしたがって、前記第2命令のうちゼロバイト長文字列を用いる部分を前記代替文字列に変換させる
ことを特徴とする請求項1記載のレプリケーションプログラム。
The conversion table defines a conversion rule that specifies conversion of a zero byte length character string on the first database into an alternative character string of 1 byte length or more on the second database;
The replication program causes the computer to convert a portion using a zero-byte length character string in the second instruction to the substitute character string in the conversion step according to the definition of the conversion rule. 1. The replication program according to 1.
前記変換テーブルは、前記第1データベース上における前記代替文字列を前記第2データベース上におけるゼロバイト長文字列に変換するよう指定する変換ルールを定義しており、
前記レプリケーションプログラムは、前記変換ステップにおいて前記コンピュータに、前記変換ルールの定義にしたがって、前記第2命令のうち前記代替文字列を用いる部分をゼロバイト長文字列に変換させる
ことを特徴とする請求項4記載のレプリケーションプログラム。
The conversion table defines a conversion rule that specifies conversion of the substitute character string on the first database into a zero-byte length character string on the second database;
The replication program, in the conversion step, causes the computer to convert a portion of the second instruction that uses the substitute character string into a zero-byte length character string according to the definition of the conversion rule. 4. The replication program according to 4.
JP2015144903A 2015-07-22 2015-07-22 Replication program Pending JP2017027349A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2015144903A JP2017027349A (en) 2015-07-22 2015-07-22 Replication program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2015144903A JP2017027349A (en) 2015-07-22 2015-07-22 Replication program

Publications (1)

Publication Number Publication Date
JP2017027349A true JP2017027349A (en) 2017-02-02

Family

ID=57946582

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2015144903A Pending JP2017027349A (en) 2015-07-22 2015-07-22 Replication program

Country Status (1)

Country Link
JP (1) JP2017027349A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101917806B1 (en) * 2017-12-22 2018-11-12 주식회사 웨어밸리 Synchronization Error Detection AND Replication Method of Database Replication System Using SQL Packet Analysis
KR20190076826A (en) * 2017-12-22 2019-07-02 주식회사 웨어밸리 Automation of sql tuning method and system using statistic sql pattern analysis
CN111831754A (en) * 2020-07-20 2020-10-27 中国工商银行股份有限公司 Method, device, system and medium for copying data in database

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101917806B1 (en) * 2017-12-22 2018-11-12 주식회사 웨어밸리 Synchronization Error Detection AND Replication Method of Database Replication System Using SQL Packet Analysis
KR20190076826A (en) * 2017-12-22 2019-07-02 주식회사 웨어밸리 Automation of sql tuning method and system using statistic sql pattern analysis
KR102127272B1 (en) 2017-12-22 2020-06-29 주식회사 웨어밸리 Automation of sql tuning method and system using statistic sql pattern analysis
US11157512B2 (en) 2017-12-22 2021-10-26 Warevalley Co., Ltd. Method and system for replicating data to heterogeneous database and detecting synchronization error of heterogeneous database through SQL packet analysis
CN111831754A (en) * 2020-07-20 2020-10-27 中国工商银行股份有限公司 Method, device, system and medium for copying data in database
CN111831754B (en) * 2020-07-20 2024-02-27 中国工商银行股份有限公司 Method, device, system and medium for copying data in database

Similar Documents

Publication Publication Date Title
US11475034B2 (en) Schemaless to relational representation conversion
US10754875B2 (en) Copying data changes to a target database
US10915544B2 (en) Transforming and loading data utilizing in-memory processing
EP2784665B1 (en) Program and version control method
US7702698B1 (en) Database replication across different database platforms
TWI412945B (en) Retrieving and persisting objects from/to relational databases
CN106933703B (en) Database data backup method and device and electronic equipment
JP6427592B2 (en) Manage data profiling operations related to data types
US8392423B2 (en) Data set index record preservation
US9460142B2 (en) Detecting renaming operations
US20060235899A1 (en) Method of migrating legacy database systems
US8412670B2 (en) Apparatus, method, and program for integrating information
US10762037B2 (en) Data processing system
JP6199439B2 (en) Database update system using spreadsheet interface
US8595190B2 (en) Methods and apparatus related to completion of large objects within a DB2 database environment
JP2018136939A (en) Method for updating database based on spreadsheet for generating update data-categorized optimal query sentence
JP2017027349A (en) Replication program
CN110083617B (en) DDL statement processing method and device, electronic device and medium
US20180275961A1 (en) Method and system for fast data comparison using accelerated and incrementally synchronized cyclic data traversal algorithm
JP2018045441A (en) Data integration method, data integration device, data processing system, and computer program
JP2018109898A (en) Data migration system
KR101024494B1 (en) Extraction method of modified data using meta data
CN110647518B (en) Data source fusion calculation method, component and device
JP7274293B2 (en) Information processing device, information processing method and program
JP5984629B2 (en) Master file difference automatic output device