TWI231908B - Table duplication method for relational database - Google Patents

Table duplication method for relational database Download PDF

Info

Publication number
TWI231908B
TWI231908B TW92137193A TW92137193A TWI231908B TW I231908 B TWI231908 B TW I231908B TW 92137193 A TW92137193 A TW 92137193A TW 92137193 A TW92137193 A TW 92137193A TW I231908 B TWI231908 B TW I231908B
Authority
TW
Taiwan
Prior art keywords
update
data
database
copying
record
Prior art date
Application number
TW92137193A
Other languages
Chinese (zh)
Other versions
TW200521742A (en
Inventor
Fu-Li Chen
Original Assignee
Digital United Inc
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 Digital United Inc filed Critical Digital United Inc
Priority to TW92137193A priority Critical patent/TWI231908B/en
Application granted granted Critical
Publication of TWI231908B publication Critical patent/TWI231908B/en
Publication of TW200521742A publication Critical patent/TW200521742A/en

Links

Landscapes

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

Abstract

Disclosed is a table duplication method for relational database by using an update log file and a refresh log file to duplicate a plurality of tables identically and completely from a master database to a slave database. The alter log file constantly keeps recording an alter sequence sequentially generated by every item of data for executing an alter command in the table of the master database. The refresh log file records the update sequence corresponding to the data committed to complete the update command as a refresh sequence based on the sequence of size. Based on the refresh sequence stored in the refresh log file, the updated data corresponding to a refresh sequence can be extracted and duplicated to the slave database. Because the refresh log file records the refresh sequence for the committed data and therefore the process of duplication is smoothly conducted without being influence by prolonged execution time and data recovery.

Description

1231908 玖、發明說明: 【發明所屬之技術領域】 尤指一種適用於關 本發明係關於一種資料複製方法 連式資料庫之表袼複製方法。 【先前技術】 10 15 地岸科技不斷演進,資料庫管理技術已廣泛 ‘二於各種產業中’而資料庫隨著時間更迭及攔位擴 所儲存的資料量將日趨龐大,且資料或表格間的關 =複雜度有時並非—台電腦主機可處理,而必須將資 &庫分散儲存在兩地(或以上)。因此,如何確保兩地資料 庫中所儲存資料的—致性,遂成為當前亟欲解決之課題。 習知之資料複製方法,係於主資料庫(刪ter database) 中建立-記錄表格(log table),用以記錄主"庫在前―次 複製過程之後所產生的全部異動資料,包括新增、修改、 及刪除資料等記錄’以當下一次欲將資料複製到副資料庫 database)時,僅需根據記錄表格中的異動内容 來更新異動資料即可’而不用將整個主資料庫的資料全部 重新複製到副資料庫中。 2〇 —請參閱圖1之時間軸示意圖,當系統在(。完成前一次 複製過程之後,主資料庫係依序於異動時間(update time)tul及u對二筆資料R1及R2進行修改,因此,記錄 表格中將依序產生1和2的更新序號;f系統於ti開始進 1231908 :_人複製過程時,由於資料R1及R2皆已於tl前被 ” € mmit),故副資料庫將會依照更新序號逐一自主瞀 料庫中複製出上述二筆修改過的資料。 、 5 、尚然而,習知之資料複製方法,將會受到資料更新時間 二】或執行駟料動作復原(rollback)的影響,而導致後續 =製作業無法進行的問題。請參閱圖2之時間軸示意圖, ^系、、先在t2元成前—次複製過程之後,主資料庫係依序於 異動時間tu3、tu4、及Μ對三筆資料R3、R4、及R5開始 ^改’並在記錄表格中產生3、4、5的更新序號;然而, 田系、、先於h右人開始進行下一次複製過程時,資料R4尚未 被提又亦即R4的提交時間(commit time)%4晚於t3,此 時右使用依照更新序號的方式來複製資料,將會使得副資 料庫在複製完R3後,需要等待下一個更新序號(即尺4的 =新)’但由於R4尚未被提交,因此副資料庫無法緊接著 15複製R4的資料’連帶導致更新序號較晚之R5的更新也無 法複製完成,R5的複製必須等到R4被提交之後才能^ 行如果R4遲遲未提交,則後續的所有複製作業將無法 進行,又,若R4係執行了資料動作復原指令,則代表R4 並未被提交,因此R4原先之更新序號將會消失,亦即副 20資料庫將永遠無法等待到所需要之序號,導致無法完成後 續之複製作業,這是使用依照更新序號所衍生的問題。另 外可能資料庫複製的方法將是使用資料庫更新紀錄 (Database Log)的方式,其複製方式是將資料庫所有的更新 紀錄下來,並放置在紀錄檔案中,副資料庫直接採用紀錄 1231908 檔案中之資料一筆筆更新即可。此種複製方式需要整個資 料庫的更新,無法只針對某個或某些表格(TaMe)更新,二 =同-筆資料更新過多次,副資料庫也需要更新多 =丰=無法採用直接最新的資料,—次複製即可,較為浪 費時間。對於線上使用並且更新量非常大之資料庫,採用 資料庫更新紀錄複製轉庫的m會較沒有效率。 由此可知,習知僅根據資料異動時間來更新資料庫之 資料複製方法仍存在有諸多缺失而有予以改進之必要。 10【發明内容】 本發明之主要目的係在提供—種關連式資料庫之表 格稷製方法’俾能將主資料庫(master细如㈣中之資料完 整複製到副資料庫(duplication database)中並能確保在= 製過程中'主資料庫仍維持在正常運作狀態。 15 本發明之另—目的係在提供-種關連式資料庫之表 格複製方法,僅需更新於前—次複製過程後所產生之里動 (包括^增、刪除、及修改)資料,而毋須複製完整資料庫 1^ ΐ料,俾能降低系統負荷、複製時間、及複雜度’並 月匕k尚糸統效能(perf〇rmance) 〇 20 本^明之再-目的係在提供-種關連式資料庫之表 格複製方法,係能一次處理複數個表格資之複製流程,以 維持表格間之一致性。 、…依據树明之—特色,所^之關料龍庫之表格 複製方法’係輔以一異動記錄檔(updatei〇g)及一更新記錄 1231908 檔(refresh log),用以將一主資料庫中之複數個表格完整複 製到一副資料庫中以完成一複製流程。在此方法中每一表 格係對應定義有一異動記錄檔及一更新記錄檔。其中,異 動記錄槽係持續記錄在主賢料庫之表格中、每一筆執行異 5動指令之資料所依序產生的異動序號(update seqUencey 而更新記錄檔則將已提交(commit)完成異動指令之資料所 對應的異動序號依照其大小以依序記錄為一更新序號 (refresh sequence)。其中’上述異動指令為下列其中之一: 新增指令、刪除指令、及修改指令。 10 本發明關連式資料庫之表格複製方法主要包括一起 始複製步驟、一判斷步驟、一篩選步驟、以及一後續複製 步驟。起始複製步驟係於一起始複製期間内、將儲存於主 貝料庫中之表格複製儲存至副資料庫中;接著將由判斷步 驟來判斷在複製期間内、各個表格所對應之更新記錄檔是 15否產生異動;若是,則繼續執行篩選步驟以篩選出更新記 錄檔中產生異動之更新序號及其對應之資料,否則即完成 本次複製流程;並執行後續複製步驟以於一後續複製期間 内、將如述產生異動之更新序號所對應的資料依序複製儲 存至副資料庫中,並接續執行判斷步驟。 【實施方式】 為能讓貴審查委員能更瞭解本發明之技術内容,特 舉較佳具體實施例說明如下。 20 1231908 本發明所提出之關連式資料庫之表格複製方法係用 以將一資料庫(即本實施例之主資料庫(master database))中 之多7表格(tables)完整的複製到另一資料庫(即本實施例 之田貝料庫(duplication database))中,且在進行複製流程 5時,主資料庫仍需保持繼續運作。 本實施例關連式資料庫之表袼複製方法主要區分為 兩大流程··包括初期將所有表袼從主資料庫複製到副資料 庫之「初次複製(initialcopy)」流程、以及往後僅將主資料 庫中產生異動之表格複製到副資料庫的「增量更新 10 (inCremental refresh)」流程。其中,主資料庫係儲存有複 數個關連式資料表格,例如一企業所儲存之員工基本資料 表格、及員工薪資表格等;或一銀行所管理之顧客資料表 格、及帳戶金額表格等。 為確保表格能完整從主資料庫複製儲存到副資料庫 15中,故本實施例係針對每一表格定義# 一異動記錄檔 (update log)及一更新記錄檔(refresh 1〇幻。異動記錄檔中儲 存有異動序號(update sequence)攔位用以即時記錄在主資 料庫之表袼中、每一筆執行過異動指令之資料的順序;更 新。己錄杬則儲存有更新序號(refresh s叫狀此匀攔位用以記 20錄已提交(commit)完成異動指令之資料所對應的順序,其 中,上述異動指令包括新增(add)指令、刪除(delete)指令、 及修改(modify)指令。 為使貴審查委員能更瞭解本實施例之異動記錄檔及 更新記錄檔之定義,煩請參閱圖3之時間軸示意圖,並請一 1231908 5 10 15 併參閱圖4所示之異動記錄檔、及圖5之更新記錄播示意 圖。本實施例係自時間Τχ開始使用異動記錄檔及更新記錄 棺來記錄在主資料庫的表格中產生異動之資料,於圖3中, G丨、kk、及k分別代表主資料庫中之資料&卜r2、们、 及糊始執行異動指令的時間,而tb丨、〜&、及^則代 表資料R1 R2、R3、及R4提交完成異動指令的時間;圖4 之異動記賴即根據執行㈣依序將每—筆f料開始執行 異動心令所產生的異動序號記錄為卜3、及4。需注意的是, 根據資料庫的理論特性,可得知#資料仍在執行過程中、 且尚未被提交時,該筆資料在耗行㈣的行程(p_ss) 中對應於異動記錄檔並不存在因此’直到時間Ty為止,由 於資料R2仍在執行先前所下達之異動指令而尚未被提 交,故在非執行異動資料尺2的行程中於&時間時所看到之 異動紀錄檔將只有異動序號為卜3、4等三筆資料,複製流 程將會WTy之前已提交之f伽、R3、及以之順序紀錄於 更新紀錄檔中,並依照異動紀錄檔之異動序號產生更新序 號,因此R3之提交時間h雖然早於^之提交時間但在 更新紀錄檔之更新序號仍然以R1為先,,進而形成如圖5 所示之更新記錄檔,顯示資料R1、R3、及尺4所對應之更新 序號分別為1、2、及3,此時R2由於尚未提交因此將不會 出現在更新紀錄標中。 需注意的是,本實施例之異動記錄檔及更新記錄檔僅 記錄有各資料所對應之鍵值(Key)及異動序號或更新序 號;當然異動記錄檔及更新記錄檔中亦可記錄有該筆資料 20 1231908 所對應的資料内容,以便進行複製流程時,可直接擷取更 新記錄檔中之更新資料來簡化複製流程,但此種方式將會 增加主資料庫之儲存空間,僅儲存鍵值將可節省主資料^ 之儲存空間,但需有額外由鍵值擷取資料所需花費的時間 5 及系統資源。 ' 接著請參閱圖6,並配合圖7之時間軸示意圖以詳述本 貫施例之作動流程,其中,以下係以將主資料庫中之單一 表格複製儲存至副資料庫之流程為例,俾簡化說明,當然 下列流程亦適用於將主資料庫中之複數個表格複製儲^ 10 副資料庫中。 首先,係自時間To開始進行初次複製(步驟S6〇1),亦 即把主資料庫之表格中的資料全部複製儲存到副資料庫 中’並於時間To前啟動異動記錄播,異動記錄播將記錄自 ΤΘ後’表格中所有產生異動之f料的異動序號。如圖7 15所示,雖然在時間Tl已完成了一開始要求的表格複製,但 在T〇至T|所形成之起始複製期Μ中,f料R5、R6、及R7 皆接收到執行異動指令的動作,且㈣以及们已提交完成 異動指令,故將在如圖8所示之異動記錄射依序記錄有異 動序號001、及〇〇3,顯見即使副資料庫中已儲存有原先表 0才。的資但田貝料庫之表格中的資料卻無法與主資料庫 之資料完全-致。為解決此不一致的問題,將會啟動一個 複製流程,此複製流程首先掃描現在之異動資料播,並據 '產生此時之更新紀錄檔,由於在τ丨之前,資料及π已 1231908 提交完成異動指令,故圖9之更新記錄檔中對應於資料以 及R7的欄位將分別記錄1及2之更新序號。 ίο 15 20 由於本實施例係執行初次複製,因此異動記錄檔及更 新屺錄輻在T〇之前尚無記錄任何内容,故當系統判斷比對 出更新記錄檔中儲存有内容時(步驟S6〇2),代表在步驟 S601的複製過程中,部分產生異動(例如新增、刪除、或修 改)的資料已提交執行完成,則接著(即時間τ〇必須擷取出 更新。己錄枯中之全部更新序號(步驟S6〇3),據以從主資料 庫中擷取出對應的異動後資料R5及R7來更新副資料庫(步 驟S604)反之,右更新記錄擋並無記錄任何内容(步驟 S曰_),代表在步驟S6G1的複製過程中,並無其他資料已被 提父,則完成本次的初次複製流程。需注意的是,若資 係執行刪除指令,表示異動後之該筆資料已不存在於主資 料庫t,故副資料庫亦必須對應刪除其中之資料;若料 係執行新增指令,則副資料庫將對應新增該筆資料内容\ 總之’副資料庫係以主資料座中 — 能mu η 胃料中各♦異動後貧料的最後狀 悲作為其複製更新之依據。 為避免往後執行多餘之複製程序,因此副資料庫中之 ί格將記錄最大更新序號(步義〇5),於本實施例中,目 月,J所記錄之最大更新序號為「 最大更新序號之更新序於(牛驟S6⑹在5己錄元後刪除小於 4斤琥(步驟S606)。如此一來,將 由比對最大更新序號、與更新記_中之 ^ :’而得知後續是否有產生異動。於本實施例中, 1至丁2所形成的複製期間内,主資料庫並無任何資料產生 12 1231908 $動’因此更新記錄射之更新序號將等於記錄在副資料 Μ的最大更新序號(步驟S6G7)’表示 格中所健存的資料係和主資料庫完全一致,因此不= 订額外複製程序,繼而可結束本實施例之初次複製流程。 5 #主資料庫和副資料庫完成初次複製流程之後,將可 根才康使用白ί貝或而求,以設定每間隔一預設期間以後、將 主貝料庫中產生異動之資料複製到副資料庫中以維持兩者 資料的一致性’例如每間隔一分鐘、數分鐘、或半小時 不等。於本實施例中’ Τ2+Δί=τ;,因此將於T3時擁取出在 10 丁2之後所建立的更新記錄檔(步驟S6〇9)俾利進行增量更新 流程,請參閱圖10之異動記錄槽,由於在丁2完成初次複製 時,資料R6仍在執行中,因此系統係保留資料以6的異動序 號,僅刪除掉資料以及尺以斤對應記錄的異動序號,又,由 =主資料庫係於tm4修改資料以,因此異動記錄檔亦記錄有 15資料R5新產生的異動序號為〇〇4 ;且在凡時,資料r5&r6 皆已提交執行完成,故圖n之更新記錄檔中係記錄以及1^ 之更新序號,俾利系統根據更新序號以自主資料庫中擷取 出異動後的R5及R6、加以複製儲存到副資料庫中(步驟 S610),直到A完成上述兩筆資料的複製,並在記錄完最大 20更新序號「4」(步驟S605)之後、刪除多餘更新序號(步驟 S606)。 由於在A至A所形成之複製期間内,主資料庫中之資 料R7係於tm5執行異動指令、並於tnS提交,因此更新記錄棺 將如圖12所示,係記錄資料R7之更新序號為5,其大於儲 13 1231908 存在田i貝料庫中之最大更新序號「4」(步驟S術),因此, 二統:可據此自主資料庫中擷取出異動後之資料R7以複 製儲存到副資料庫(步驟S6〇8)。 5 10 15 —根據上述之說明,顯示本發明係可根據資料庫中針對 二:格:定義之更新記錄檔的更新序號、以進行資料複 红°亦即料需執行異動指令時,將先依序在里動 :;=(update log)中記錄其異動序號(up— :資料已提交執行完成異動指令後,才會根據各資料斤對 =動序號大小、以依序在更新記錄播 ,料之更新序號("Μ—)。如此-來由Ϊ 尚未被提交的資料將不會在更新記錄檔中記皮 在進行資料複製時,受到資料更新時 間過長、或執仃動作復原⑽lbaek)而導致後續複製 的=,俾能將主資料庫中之資料完整i j貝㈣中’同時可確保在複製過程中 維持在正常運作狀態。此外,本發 貝㈣乃 :程時、需將主資料庫中的全部資料表二=欠= 貝料庫中之外’後續流程僅需複製產生異動之料子5田J 有效提高系統效能;且本發明係適用於同 ^,將可 資料複製至副資料庫’而不至於影響到資料間二格之 一致性,實為一大進步。 〗的關連性與 上述貫施例僅係為了方便說明而舉例而 主張之權利範圍自應以申請專利範圍 :本發明所 於上述實施例。 ”、、旱’而非僅限 20 1231908 【圖式簡單說明】 圖1係為一時間軸示意圖。 圖2係為另一時間軸示意圖。 5 圖3係本發明一較佳實施例之時間軸示意圖一。 圖4係本發明一較佳實施例之異動記錄檔之示意圖 圖5係本發明一較佳實施例之更新記錄檔之示意圖 圖6係本發明一較佳實施例之流程圖。 一 10 15 圖7係本發明一輕伟眘你γ丨 钗佳貫轭例之時間軸示意圖二 ==ΓΤι時所記錄之異動記錄二 =為二:,寺, 67 、”、"日^間丁3時所記錄之里動"V棘 圖11係為圖7在時間Τ3時所 之/、動屺錄檔 圖12係為圖7在時間&時所^、彔之更新記錄檔1231908 发明 Description of the invention: [Technical field to which the invention belongs] In particular, the present invention relates to a method for copying data. [Previous technology] 10 15 Land and shore technology is constantly evolving, database management technology has been widely used in various industries, and the amount of stored data will increase with the change of time and expansion of storage space. Off = complexity is sometimes not-a computer host can handle it, and the data & library must be stored in two places (or more). Therefore, how to ensure the consistency of the data stored in the databases of the two places has become an issue to be solved urgently. The conventional method of copying data is to create a log table in the main database (ter database) to record all the transaction data generated by the main " database after the previous and previous copying processes, including adding new data. , Modify, and delete records such as 'the next time you want to copy data to the secondary database database), you only need to update the changed data according to the changes in the record form' instead of all the data in the entire main database Copy it back into the secondary library. 2〇—Please refer to the timeline diagram in Figure 1. When the system completes the previous copy process, the master database will modify the two records R1 and R2 at the update time tul and u in sequence. Therefore, the updated serial numbers of 1 and 2 will be generated in the record form in sequence; the f system starts to enter 1231908 at ti: _ When the copying process of the person, both the data R1 and R2 have been "tl mm" before tl, so the auxiliary database The above two modified data will be copied one by one in the autonomous database according to the update serial number. 5. However, the conventional data copying method will be subject to the data update time II] or perform rollback. The result is that the follow-up operation cannot be performed. Please refer to the schematic diagram of the time axis in Figure 2. ^ Department, first, before t2 yuan is completed-after the copy process, the main database is in sequence at the change time tu3, tu4, and M began to modify the three data R3, R4, and R5 and generated the updated serial numbers of 3, 4, 5 in the record form; however, the field system, and before the right person began the next copy process At the time, the data R4 had not been mentioned That is, the commit time of R4% 4 is later than t3. At this time, the right to use the method of copying data according to the update sequence number will make the secondary database wait for the next update sequence number after copying R3 (that is, the ruler) 4 = new) 'But since R4 has not been submitted, the secondary database cannot copy R4's data immediately after 15'. As a result, the update of R5 with a later update number cannot be copied. R5 must be copied until R4 is submitted. Only ^ line. If R4 is not submitted late, all subsequent copying operations will not be performed. If R4 executes the data action recovery instruction, it means that R4 has not been submitted, so the original update serial number of R4 will disappear. That is, the secondary 20 database will never be able to wait for the required serial number, resulting in the inability to complete subsequent replication operations. This is a problem derived from using the updated serial number. In addition, the method of database replication may be to use the database to update records ( Database Log) method, its replication method is to record all updates of the database and place them in the log file, and the sub database directly uses the log 1 231908 The data in the file can be updated in one stroke. This copying method requires the entire database to be updated. It cannot be updated only for one or some tables (TaMe). Two = the same-pen data has been updated multiple times, and the sub database is also updated. Need to update more = abundance = can not use the latest data directly, one copy is sufficient, it is a waste of time. For databases that are used online and have a very large amount of updates, it will be less efficient to use the database update record to copy the database. It can be seen that there are still many shortcomings in the method of copying data that are used to update the database based on the time of data changes. It is necessary to improve the method. 10 [Summary of the Invention] The main purpose of the present invention is to provide a related database The form control method can not completely copy the data in the master database (such as the details in the master to the duplication database) and can ensure that the 'master database is still maintained in a normal operating state during the process. 15 Another purpose of the present invention is to provide a method of copying tables in a connected database, which only needs to update the moving (including adding, deleting, and modifying) data generated after the previous copying process without the need to Copying a complete database 1 ^ It is not possible to reduce system load, copy time, and complexity. The performance of the system is also perfomance. 20 The purpose of this book is to provide a kind of connection. The form copying method of the database can handle the copying process of multiple form materials at one time to maintain the consistency between the forms. , ... According to Shumingzhi—features, the method of copying the table of the material library is supplemented by a transaction log (updatei0g) and an update log 1231908 (refresh log), which is used to copy a master database The multiple tables in the table are copied to a database to complete a copy process. In this method, each table is correspondingly defined with a transaction log file and an update log file. Among them, the transaction record slot is continuously recorded in the table of the main sage library, and each transaction serial number (update seqUencey generated from the execution of the data of the 5 operation instructions) is updated. The update log file will be submitted to complete the transaction instruction. The transaction sequence number corresponding to the data is sequentially recorded as a refresh sequence according to its size. The above-mentioned transaction sequence is one of the following: a new command, a delete command, and a modification command. 10 Related Types of the Invention The table copying method of the database mainly includes an initial copying step, a judging step, a screening step, and a subsequent copying step. The initial copying step is to copy the tables stored in the main shell database during an initial copying period. Stored in the auxiliary database; then the judgment step will determine whether the update log file corresponding to each table during the copy period is 15 whether there is a change; if it is, continue to perform the filtering step to filter out the update that has a change in the update log file Serial number and its corresponding data, otherwise this copy process is completed; and subsequent copy steps are performed During a subsequent copy period, the data corresponding to the update serial number that has changed as described above is sequentially copied and stored in the auxiliary database, and the judgment steps are continuously performed. [Implementation Method] In order to allow your review committee to understand this The technical content of the invention, and specific preferred embodiments are described below. 20 1231908 The table copy method of the related database provided by the present invention is used to copy a database (that is, the master database of this embodiment). As many as 7 tables in) are completely copied to another database (that is, the duplication database of this embodiment), and the main database still needs to continue to operate when the replication process 5 is performed. The table 袼 copying method of the connected database in this embodiment is mainly divided into two major processes ... including the "initial copy" process of initially copying all the tables 袼 from the main database to the sub database, and only the subsequent copying The changed table in the primary database is copied to the "incremental refresh" process of the secondary database. Among them, the primary database stores multiple Continuous data forms, such as employee basic data forms and salary forms stored by an enterprise; or customer data forms and account amount forms managed by a bank. To ensure that forms can be copied from the main database and stored to In the auxiliary database 15, the present embodiment defines #an update log and an update log (refresh 10) for each table. The update sequence stores an update sequence block. It is used to record in real time the order of the data of each transaction executed in the table of the main database; update. The recorded record stores the update serial number (refresh s called this uniform stop to record 20 records have been submitted (Commit) The order corresponding to the completion of the data of the transaction instruction. The above transaction instruction includes an add instruction, a delete instruction, and a modify instruction. In order to make your reviewing committee better understand the definition of the change record file and update record file in this embodiment, please refer to the timeline diagram in FIG. 3, and please refer to the change record file shown in FIG. 1231908 5 10 15 and FIG. 5 is a schematic diagram of update recording. This embodiment uses the change log file and the updated record coffin to record the data that caused the change in the table of the main database since time Tχ. In Figure 3, G 丨, kk, and k represent the data in the main database, respectively. & Bu r2, we, and the time when the execution of the transaction instruction was started, and tb 丨, ~ &, and ^ represent the time when the data R1 R2, R3, and R4 submitted the completion of the transaction instruction; According to the order of execution, the transaction serial numbers generated by each of the f materials starting to execute the heartbeat order are recorded as Bu 3 and 4. It should be noted that according to the theoretical characteristics of the database, it can be known that when the #data is still in execution and has not been submitted, the data does not exist in the travel schedule (p_ss) corresponding to the transaction log Therefore, 'until time Ty, because the data R2 is still executing the previously issued change order and has not yet been submitted, the non-execution change data rule 2's itinerary at the time of & time will only have the change. The serial number is three pieces of data, such as Bu 3, 4. The copying process will record the f gamma, R3, and the order submitted by Wty in the update log file, and generate the update serial number according to the transaction serial number of the transaction log file. Although the submission time h is earlier than the submission time of ^, the update serial number in the update log file still takes R1 as the first, and then an update log file as shown in FIG. 5 is formed, showing the corresponding data of R1, R3, and ruler 4 The update serial numbers are 1, 2, and 3 respectively. At this time, R2 will not appear in the update record target because it has not been submitted. It should be noted that the change log file and the update log file of this embodiment only record the key corresponding to each data and the change serial number or update serial number; of course, the change log file and the update log file may also record the same. The data content corresponding to the data 20 1231908, so that during the copying process, you can directly retrieve the update data in the update log file to simplify the copying process, but this method will increase the storage space of the main database and only store key values It will save the storage space of the master data ^, but it will require additional time and system resources required to retrieve data by key value5. 'Please refer to FIG. 6 and the timeline diagram of FIG. 7 to describe the operation flow of this embodiment. Among them, the following is a process of copying and storing a single table in the main database to the sub database, as an example.俾 Simplify the description, of course, the following process also applies to copying and storing multiple tables in the main database ^ 10 secondary databases. First, the first copy is started from time To (step S601), that is, all the data in the table of the main database is copied and stored in the secondary database 'and the transaction recording broadcast is started before the time To The transaction numbers of all the materials in the table after TΘ will be recorded. As shown in Figure 7-15, although the initial copy of the form required at time Tl has been completed, during the initial copy period M formed from T0 to T |, all the data R5, R6, and R7 are received and executed. The action of the change order, and the change order has been submitted, so we will record the change order numbers 001 and 〇03 in sequence in the change record shot shown in Figure 8. It is obvious that even if the original database has been stored in the auxiliary database, Table 0 is only. The information in the table of Tianbei Library cannot be completely consistent with the information in the main database. In order to resolve this inconsistency, a copy process will be started. This copy process first scans the current data broadcast and generates an update log file at this time. Since τ 丨, the data and π have been submitted to complete the change. Instructions, so the fields corresponding to the data and R7 in the update log file of Figure 9 will record the update serial numbers of 1 and 2, respectively. ίο 15 20 Since this embodiment is the first copy, the change log file and update log record have not recorded any content before T0, so when the system judges that the update log file has content stored (step S6〇) 2) It means that during the copying process of step S601, part of the data (such as adding, deleting, or modifying) that has undergone changes has been submitted for execution, and then (that is, time τ〇 must be retrieved and updated. All that has been recorded) Update the serial number (step S603) to update the secondary database by extracting the corresponding changed data R5 and R7 from the main database (step S604). On the contrary, the right update record file does not record anything (step S _), Which means that during the copying process of step S6G1, no other materials have been raised, and the initial copying process is completed. It should be noted that if the asset executes the delete instruction, it means that the data has been changed after the change. Does not exist in the main database t, so the sub-database must also delete the data in it; if the material is added, the sub-database will correspondingly add the data content \ In short, the sub-database It is based on the main data base — the last state of the poor material after each change in the stomach material □ as the basis for its copying and updating. In order to avoid performing redundant copying procedures in the future, the grid in the subsidiary database will record The maximum update sequence number (step meaning 05). In this embodiment, the maximum update sequence number recorded by J is "The update sequence of the maximum update sequence number is in (Niu S6), after deleting 5 characters, delete less than 4 catties. (Step S606). In this way, the maximum update sequence number and ^: 'in the update record _ are compared to determine whether there is a subsequent change. In this embodiment, within the replication period formed by 1 to D2 , There is no data in the main database. 12 1231908 $ "'Therefore the update serial number of the update record will be equal to the maximum update serial number recorded in the secondary data M (step S6G7). It ’s completely the same, so do n’t = order an extra copying procedure, and then you can end the initial copying process of this embodiment. 5 #After the primary copying process of the main database and the sub-database is completed, you can use Bai Baibei or ask, To set After a preset period of time, copy the changed data in the main shell database to the sub-database to maintain the consistency of the two data. For example, every one minute, several minutes, or half an hour. In the embodiment, 'T2 + Δί = τ ;, therefore, the update record file created after 10 d2 (step S6〇9) will be taken out at T3 to facilitate the incremental update process. Please refer to the transaction record in FIG. 10 Since the data R6 is still being executed when Ding 2 completes the first copy, the system keeps the transaction serial number of 6 and only deletes the data and the transaction serial number corresponding to the rule. The main database is The data is modified at tm4, so the change log file also records 15 data R5. The newly generated change serial number is 〇04; and at all times, the data r5 & r6 have been submitted for execution, so in the update log file of Figure n The system records and the update serial number of 1 ^. The profit system retrieves the changed R5 and R6 from the autonomous database according to the updated serial number, and stores them in the secondary database (step S610), until A completes the above two data. Copy and After recording the maximum 20 update numbers "4" (step S605), the unnecessary update numbers are deleted (step S606). During the replication period formed by A to A, the data R7 in the main database was executed at tm5 and submitted at tnS. Therefore, the update record coffin will be shown in Figure 12, and the update serial number of the record data R7 is 5, which is greater than the storage 13 1231908 The largest update serial number "4" stored in the Tian i shellfish storehouse (step S operation). Therefore, Ertong: You can extract the changed data R7 from the autonomous database to copy and save to Secondary database (step S608). 5 10 15 —According to the above description, it is shown that the present invention can be based on the update serial number of the update log file defined in the database for two: grid: for data rediscovery. The sequence is recorded in:; = (update log). The sequence number of the transaction is recorded in the update log. The update serial number (" Μ—). In this way-the data that has not been submitted will not be recorded in the update log file. When copying the data, the data will be updated for a long time or the action will be restored (lbaek) As a result of the subsequent replication, the data in the main database can not be completely completed, and at the same time, it can ensure that the normal operation state is maintained during the replication process. In addition, this post is: during the process, all the data tables in the main database must be equal to two = owed = outside of the shell database. 'The subsequent process only needs to copy the material that has changed. 5 Tian J effectively improves system performance; and The present invention is applicable to the same, copying the data to the auxiliary database 'without affecting the consistency of the two grids between the data, which is a great progress. The relevance of the above and the above-mentioned embodiments are merely examples for the convenience of explanation and the scope of rights claimed should be the scope of patent application: the present invention is in the above-mentioned embodiments. ",, drought" instead of only 20 1231908 [Schematic description] Figure 1 is a schematic diagram of a time axis. Figure 2 is a schematic diagram of another time axis. 5 Figure 3 is a time axis of a preferred embodiment of the present invention Schematic diagram 1. Fig. 4 is a schematic diagram of a change log file according to a preferred embodiment of the present invention. Fig. 5 is a schematic diagram of a update log file according to a preferred embodiment of the present invention. Fig. 6 is a flowchart of a preferred embodiment of the present invention. 10 15 Figure 7 is a schematic diagram of the time axis of a light and careful example of the present invention. = = 动 贯 Jiaguan yoke example of the time axis 2 == ΓΤι recorded when the second record of change == 2: Temple, 67 Figure 11 at the time of Ding " V thorn Figure 11 is the recording file of Figure 7 at time T3, Figure 12 is the updated recording file of Figure 7 at time &

錄之更新記錄 檔 【圖號說明】 無Record update record file [Illustration of drawing number] None

1515

Claims (1)

1231908 拾、申請專利範圍·· 二1 · 一種關連式資料庫之表格複製方法,係辅以一異動 ==及一更新記錄檔,用以將一主資料庫中之複數個表 複製到一副資料冑中以完成一複製流程,每一表格 係對應定義有一異動記錄檔及一更新記錄; ,持續記錄該主資料庫之表格中每一筆執行一異= 料所依:產生的異動序號,該更新記錄檔係將已提交 兀、亥異動指令之該筆資料所對應的異動序 10 15 20 =序記料―更轉號,其中,㈣動指令係選自 中之一 ·新增指令、刪 括下列步驟: 及““曰令,該方法包 一起始複製步驟,係於一 該主資料座中i I 期間内、將儲存於 貝㈣中之以表格複製儲存至該❹料庫中. -判斷步驟,係判斷於該複製期間新 檔是否產生異動,若是,則繼續執行下列c己錄 該複製流程: 刃乂驟,否則完成 一筛選步驟’係篩選出料更槽 更新序號及其對應之資料;以及 π彳田中產生異動之 一後續複製步驟,係於一 … 生異動之更新序號所對應的資料::::間内、將該等產 庫中,並繼續執行該判斷步驟。 是i儲存至δ亥副資料 2.如申請專利範圍第丨項所述之、 複製步驟係於該起始複製期間内、,方法,其中,該起始 庫中之全部表格複製儲存至=儲存於該主資料 16 a^19〇8 3 ·如申凊專利範圍第2項 步驟係判斷該更新記錄檔是否二::方法,其中,該判斷 執行該筛選步驟。凉有内容,若是’則繼續 4. 如申請專利範圍第2 步驟係擁取出該等更新記錄檔= 方法,其中,該筛選 之資料。 *中之全部更新序號及其對應 5. 如申請專利範圍第丨項所 ίο 15 20 複製步驟係包括下列步驟:斤攻之方法’其中’該起始 錄二)及係擁取完成前—次複製流程後所建立之更新記 料二更新記錄檔記錄之更新序㈣ 枓依序複製儲存到該副資料庫中。 =如中請專利範圍第i項所述之方法,其中,該㈣ 複製步驟係包括下列步驟: (B1)係於-後績複製期間内、將該等產生異動之更 新序號所對應的資料依序複製料至㈣㈣庫中; (B2)係儲存該更新記錄檔中之最大更新序號;以及 、_係刪除所有小於該最大更新序號的更新序號, 並繼續執行該判斷步驟。 7·如申„月專利範圍第6項所述之方法,其中,於步驟 (B2)中’該更新記錄檔中之最大更新序號係記錄於該副資 料庫中,且該步驟(B3)係刪除儲存於該副資料庫中、所有 小於該最大更新序號的更新序號。 17 1231908 8.如申請專利範圍第6項所述 步驟係比對該等更新記錄播尹之〆Ί’該判斷 儲存之最大更新序號,若是=新序號是否大於已 」甲”月專利乾圍第!項所述之方法, 記錄播及該更新記錄檔中尚館存 / 5亥異動 號所對應之資料,且該後續複序號及更新序 ^ ^驟係於該後續複製期間 内自,亥更新,己錄檔中將該等產生 的資料依序複製儲存至該副資料庫中。’ ^ ,心 ίο 15 20 …10.如申請專利範圍第1所述之方法,其中,該後續 複製步驟係於該後續複製期間内、 、 該等產生異動之更新序號所對⑼亥主貢料庫中掏取出 副資料庫中。序柄對應的貧料依序複製儲存至該 …11·如申請專利範圍第1項所述之方法,其中,若一筆 資料尚未提交完成該異動指令, — 號係記錄無效Μ容。 心#料對應之更新序 丨2·如申請專利範圍第1項所述之方法,立中,若一筆 行該異動指令過程中、執行—復原指令,則該筆 -貝枓對應之更新序號係記錄無效之内容。 ^如申請專利範圍第i項所述之方法,其中,於執行 邊複“程時、該主資料庫仍持續正常運作。 181231908 Scope of patent application and application ··· 2 · A form copying method of a connected database, supplemented by a change == and an update record file, for copying multiple tables in a main database to a pair In the data file, a copying process is completed, and each table is correspondingly defined with a transaction log file and an update record; and each record in the table of the main database is continuously executed with a different operation = the material is dependent on: the generated transaction serial number, the The update record file is the sequence of the changes corresponding to the data that has been submitted to the Wu and Hai change orders. 10 15 20 = Sequence records-more numbers, in which the automatic instructions are selected from one of the following: • Add instructions, delete Include the following steps: "" "The command, this method includes an initial copying step, in a period of time i I in the master data base, copy the table stored in the shellfish to the library.- The judging step is to judge whether there is a change in the new file during the copying. If so, continue to perform the following c. Record the copying process: otherwise, complete a screening step. And its corresponding data; and one of the subsequent copying steps in the π 彳 field where a change occurs, which is related to the data corresponding to the update serial number of the change: :::, in the production warehouse, and continue to execute the judgment step. Yes i is stored to δ Hai secondary data 2. As described in item 丨 of the scope of the patent application, the copying step is within the initial copying period, the method, wherein all the tables in the starting library are copied and stored to = store In the master data 16 a ^ 19〇3 3, if the second step of the patent application scope is to determine whether the update record file is 2 :: method, wherein the judgment performs the screening step. If there is content, continue. 4. If the second step of the scope of patent application is to take out the update record file = method, of which the filtered data. * All the updated serial numbers in * and their corresponding 5. As in the scope of the application for patent application 丨 15 20 Copying steps include the following steps: the method of attacking 'where' the starting record 2) and before the completion of the capture-times Update order created after copying process 2 Update order of update log file 枓 复制 Copy and store to the secondary database in order. = The method as described in item i of the patent scope, wherein the 步骤 copying step includes the following steps: (B1) During the period of subsequent performance copying, the data corresponding to the update serial number that caused the change is based on (B2) stores the maximum update serial number in the update log file; and, _ deletes all update serial numbers that are less than the maximum update serial number, and continues to perform the determination step. 7. The method described in claim 6 of the patent scope, wherein in step (B2), the maximum update serial number in the update log file is recorded in the subsidiary database, and step (B3) is Delete all update serial numbers stored in the secondary database that are smaller than the maximum update serial number. 17 1231908 8. The steps described in item 6 of the scope of patent application are compared to the update records broadcast Yin Zhi'an. The maximum update serial number, if it is = whether the new serial number is greater than the method described in the "A" month patent dry encirclement item !, record the broadcast and the data corresponding to the Shangguancun / 50 Hai change number in the update record file, and the follow-up The serial number and update sequence ^ ^ steps are sequentially copied and stored in the sub-database during the subsequent copy period, and updated in the recorded file. '^ , 心 ίο 15 20… 10 The method as described in the first scope of the patent application, wherein the subsequent copying step is to extract the secondary database from the main tribute library of Wuhai during the subsequent copying period and the update serial number that caused the change. Corresponding poverty Sequentially copy and save to the ... 11. The method as described in item 1 of the scope of patent application, wherein, if a piece of data has not been submitted to complete the transaction instruction, — the number is the record invalid capacity. · As in the method described in item 1 of the scope of patent application, Lizhong, if the transaction instruction is executed and the recovery instruction is executed in a row, the update serial number corresponding to the pen-beam is the invalid content of the record. The method described in item i of the scope, in which the master database continues to operate normally while performing the side-recovery process. 18
TW92137193A 2003-12-26 2003-12-26 Table duplication method for relational database TWI231908B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW92137193A TWI231908B (en) 2003-12-26 2003-12-26 Table duplication method for relational database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW92137193A TWI231908B (en) 2003-12-26 2003-12-26 Table duplication method for relational database

Publications (2)

Publication Number Publication Date
TWI231908B true TWI231908B (en) 2005-05-01
TW200521742A TW200521742A (en) 2005-07-01

Family

ID=36251072

Family Applications (1)

Application Number Title Priority Date Filing Date
TW92137193A TWI231908B (en) 2003-12-26 2003-12-26 Table duplication method for relational database

Country Status (1)

Country Link
TW (1) TWI231908B (en)

Also Published As

Publication number Publication date
TW200521742A (en) 2005-07-01

Similar Documents

Publication Publication Date Title
CN111143389B (en) Transaction execution method and device, computer equipment and storage medium
US8788457B2 (en) Ensuring that the archival data deleted in relational source table is already stored in relational target table
JP6448609B2 (en) Data acquisition method and system
CN102197365B (en) Atomic multiple modification of data in a distributed memory system
US8782070B2 (en) Data pattern for storing information, including associated version and audit information for use in data management
JP2022511084A (en) Systems and methods for augmenting database applications with blockchain technology
CN109992628B (en) Data synchronization method, device, server and computer readable storage medium
US8572027B2 (en) Performing synchronization among relational database tables with minimal contention
CN101183322B (en) Method for deferred logging and apparatus thereof
CN108369601B (en) Promoting attributes in relational structured data
US20110145201A1 (en) Database mirroring
CN108369599A (en) Duplication control between redundant data center
CN100365632C (en) A Processing Method for Realizing Transaction Consistency Between Memory Data and Database Data
US11422970B2 (en) Handling of data archiving events in a replication system
JP2006018796A (en) Data processing method and apparatus, storage apparatus and processing program therefor
WO2025086860A1 (en) Data table processing method and apparatus, computer device, and readable storage medium
CN114780286B (en) Data disaster recovery method, device, equipment and readable storage medium
US20060004877A1 (en) Method and system for data processing with data replication for the same
JP2017027326A (en) Storage system and storage system program
EP3944094B1 (en) Parallel processing of changes in a distributed system
US12248486B2 (en) System for creating a dataset network
TWI231908B (en) Table duplication method for relational database
CN110543485A (en) Block chain reservation filing method based on snapshot
US20130166508A1 (en) Multiphase Approach To Data Availability
CN117435584A (en) A repair method for multi-source business data based on offline data warehouse

Legal Events

Date Code Title Description
MM4A Annulment or lapse of patent due to non-payment of fees
MM4A Annulment or lapse of patent due to non-payment of fees