A Sybase ASE database deleted data recovery method and device

By analyzing and restoring the system data and table structure of the Sybase ASE database, combined with the table structure matching algorithm, the recovery of deleted data is achieved, and the problem of lack of data recovery methods in the existing technology is solved.

CN114398341BActive Publication Date: 2025-02-11XIAMEN MEIYA PICO INFORMATION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111670838.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-31
Publication Date
2025-02-11
Estimated Expiration
2041-12-31

AI Technical Summary

Technical Problem

There is a lack of recovery methods for deleting data in Sybase ASE database in the prior art, resulting in the inability to effectively recover deleted data.

Method used

By analyzing and restoring the system data of the Master database, obtaining the database list, data table list and data page list, and combining the table structure matching algorithm to restore the deleted records.

Benefits of technology

It realizes effective recovery of data deleted in Sybase ASE database, ensuring the recoverability of data deleted in the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114398341B_ABST
    Figure CN114398341B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for recovering deleted data of Sybase ASE database, including parsing and recovering system data of Master database, obtaining a list containing respective attributes corresponding to each database, forming a database list set DS; extracting lists of all data tables contained in the database to form a list set TS; reading data page node depth indexes through table IDs of all data tables contained in the database, obtaining lists of all data pages contained in each data table, thereby forming a data page list set PS; parsing and recovering data pages in PS according to the index list of elements in PS, thereby successively parsing and recovering each data table, and forming a record list set RS with all record lists; parsing records of the record list set RS of all data pages starting from the record index address according to the system table record format, thereby recovering deleted records. The recovery method of Sybase ASE database is innovatively designed, so that the deleted data of Sybase ASE database can be smoothly recovered.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of information security, and in particular to a method and device for recovering deleted data of a Sybase ASE database. Background Art

[0002] Sybase is a relational database management system developed by Sybase Corporation of the United States. It is a typical large-scale database system in a client or server environment on a UNIX or Windows NT platform. Adaptive Server Enterprise (ASE) is Sybase's flagship RDBMS product. Sybase database is widely used in telecommunications, securities, finance, government, transportation and energy fields, and in the field of forensics, Sybase database forensics technology is explicitly included in the technical specifications for the construction of national network security laboratories. After fully studying the data storage structure of the Sybase ASE database, the present invention proposes a method for recovering deleted data from the Sybase ASE database.

[0003] Sybase ASE database is a relational database system mainly used in the fields of telecommunications, finance, government, etc. Currently, there is no technical research or product on the market for recovering deleted data from Sybase ASE database. After studying the storage structure and data deletion mechanism of Sybase ASE database, the present invention proposes a method for recovering deleted records, tables and databases from Sybase ASE database. Summary of the invention

[0004] The present invention proposes a method and device for recovering deleted data of a Sybase ASE database to solve the above-mentioned defects of the prior art.

[0005] In one aspect, the present invention provides a method for recovering deleted data from a Sybase ASE database, the method comprising the following steps:

[0006] S1: parse and restore the system data of the Master database, obtain the list containing the respective attributes corresponding to each database, and form a database list set DS;

[0007] S2: traverse the elements in the database list set DS, parse and restore the database in turn according to the list corresponding to the database, thereby extracting the list of all data tables contained in the database to form a list set TS, and at the same time obtain the data action area list AS of the database;

[0008] S3: Scan the database's action area according to the data action area list AS, and read the data page node depth index through the table IDs of all data tables contained in the database, and obtain all data page lists contained in each data table, thereby forming a data page list set PS;

[0009] S4: traverse the data page list set PS, parse and restore the data pages in the PS according to the index list of the elements in the PS, and parse and restore each data table in turn, obtain the record list of each data table, and form all the record lists into a record list set RS;

[0010] S5: Parse and restore the user table records to obtain the record list set RS of all data pages, then read the index list of the elements in the PS to obtain the record index address, and parse the records of the record list set RS of all data pages starting from the record index address according to the system table record format, so as to restore the deleted records.

[0011] The above method is based on the Sybase database storage structure and data deletion mechanism. It analyzes the relationship between the device, database, system table, data page, record structure and the data deletion mechanism, and combines the table structure matching algorithm to recover the deleted data.

[0012] In a specific embodiment, the S1 specifically includes:

[0013] S101: Read the data page size PageSize from the 56th byte of the master device header;

[0014] S102: Read the size of the system database master from the 11th byte of the master device header;

[0015] S103: Execute S3 to obtain all the data page list sets PS of each data table within the area of ​​the master database;

[0016] S104: according to the fixed table ID value of the system table sysdevices, sysdatabases, sysusages, find the data page list set PS of the data table corresponding to the fixed table ID;

[0017] S105: Execute S4 through the fixed field list and data page list of the system table, and parse the data pages in sequence to obtain all the record list sets RS;

[0018] S106: traverse the record list set RS of the sysdatabases table in sequence, obtain all database names and database IDs, associate the database ID with the sysusages table to obtain the data application area list AS, database creation time, user ID, and obtain the status of the database through the record status, thereby obtaining the database list set DS; wherein, when the record status is normal, it indicates a normal database, and when the record status is deleted, it indicates a deleted database;

[0019] S107: Execute S2 to parse and restore the database list set DS in sequence, and obtain the list set TS of each database.

[0020] In a specific embodiment, the S2 specifically includes:

[0021] S201: Set database D i is an element in the database list set DS;

[0022] S202: Take D i The data action area list AS of the database, execute S3, and obtain all the data page list sets PS of each data table within the data action area of ​​the database;

[0023] S203: Find the corresponding table data page list through the fixed table ID value of the system table sysobjects and syscolumns;

[0024] S204: Execute S4, and parse the data pages in sequence through the fixed field lists of the system tables sysobjects and syscolumns to obtain the record list set RS;

[0025] S205: traverse all the record list sets RS of the system sysobjects in sequence, take the records of the user table type; obtain the table name of the data table, the table ID of the data table, the creation time of the data table, obtain the status according to whether the record is deleted, associate syscolumns with the table ID of the data table to obtain a list of all fields of the data table, and search for the data page list set PS of the data table through the table ID, so as to obtain the list set TS;

[0026] S206: Execute S5 through the fixed field list and data page list of the system table, and parse the data pages in sequence to obtain all the record list sets RS.

[0027] In a specific embodiment, the S3 specifically includes:

[0028] S301: Set CurPageNo as the current page number, and the initial value of CurPageNo is 0;i is an element in the data action area list AS, and the initial value of i is 0;

[0029] S302: Set the initial value of offset to A i The starting address of the i size;

[0030] S303: If offset is less than size, execute S304, otherwise i is incremented by 1, and if i is less than the number of elements in the data action area list AS, jump to S302, otherwise end;

[0031] S304: From A i The data of PageSize size is read from the offset position and recorded as Buffer until A is reached. i The size of i is increased by 1 to continue reading the next data area until the end;

[0032] S305: Read the table page number PageNo from the Buffer offset 0 bytes, read the table ID from the offset 12 bytes, read the data page node depth Level from the offset 22 bytes, and read the data page node depth index ID from the offset 23 bytes;

[0033] S306: If the table ID is not equal to 0, and CurPageNo is equal to PageNo, and the node depth is equal to 0, and the index ID is equal to 0, then the data page is a valid data page and is classified into the corresponding data page list set PS by the table ID; otherwise, the data page is discarded as a non-data page;

[0034] S307: CurPageNo is incremented by 1, offset is incremented by PageSize, and then the process jumps to S302.

[0035] In a specific embodiment, the S4 specifically includes:

[0036] S401: Let T be a data table, and the number of fields in data table T be FieldCnt;

[0037] S402: The number of fixed-length fields is calculated as FixLenCnt1 through the field list of T, the total length of the fixed-length fields is FixLen, and the number of variable-length fields is VarLenCnt1;

[0038] S403: Assume that the data page list set PS is the data page list of T, P i is an element of the data page list set PS, and the initial value of i is set to 0;

[0039] S404: Read P iThe index list of the data page is obtained by starting from the record index address and parsing the records according to the system table record format; if the fourth bit of the record status value Status is 1, it indicates a deleted record, and if it is 0, it indicates a normal record; thereby obtaining the record list set RS of the data page;

[0040] S405: i is increased by 1. If i is less than the number of elements in the data page list set PS, the process jumps to S404, otherwise, the process ends.

[0041] In a specific embodiment, the S5 specifically includes:

[0042] S501: Let T be a data table, and the number of fields in data table T be FieldCnt;

[0043] S502: The number of fixed-length fields is calculated as FixLenCnt1 through the field list of T, the total length of the fixed-length fields is FixLen, and the number of variable-length fields is VarCnt1;

[0044] S503: Assume that the data page list set PS is the data page list of T, P i is an element of the data page list set PS, and the initial value of i is set to 0;

[0045] S504: Read P i The number of records in the page header is RecordCnt. Read from the end of the page forward according to RecordCnt to obtain the record index address in sequence. Starting from the record index address, parse the record according to the system table record format. Thus, all normal records of the data page are obtained.

[0046] S505: Set the end position of the last normal record as offset. If there is no normal record in the data page, then set offset to the end position of the page header 32.

[0047] S506: If offset is less than PageSize-RecordCnt*2-4, then offset is incremented by 1, and the record is executed in S507; otherwise, i is incremented by 1, and if i is less than the number of elements in the data page list set PS, the process jumps to S504, otherwise, the process ends;

[0048] S507: Assuming that the data record starting from the offset position is a deleted data record, then read the variable length field number VarCnt, record sequence number RecordNo, fixed length field data FixLenData, total record length RecordLen, and variable length field index list VarLenIndexs of the record according to the record structure of the user table;

[0049] S508: If VarCnt is not equal to VarCnt1 or RecordLen is greater than or equal to PageSize, the record is invalid, and Offset is increased by 1 and the process jumps to S506;

[0050] S509: If VarCnt1 is greater than 0 and RecordLen is less than FixLen+4 or VarCnt1 is equal to 0 and RecordLen is not equal to FixLen+2, the record is invalid, and Offset is increased by 1 and the process jumps to S506;

[0051] S510: If VarCnt1 is greater than 0, the address range of each variable-length field in VarLenIndexs is not within the variable-length data range, or each address is not increasing in sequence, or the number of bytes occupied by the end address plus the variable-length field index is not equal to RecordLen, then the record is invalid, and Offset is increased by 1 and jumps to S506. Otherwise, the record is a valid deletion record, and Offset is increased by RecordLen and jumps to S506.

[0052] In a specific embodiment, the database list set DS specifically includes:

[0053] Assume that DS = {D1, D2, D3, ..., D n}, where each element D i Contains the following attributes: database ID, database name, database creation time, user ID, a list of data scopes of the data in the database, a list of all data tables contained in the database, and database status, where the database status includes normal and deleted.

[0054] In a specific embodiment, the list set TS specifically includes:

[0055] Assume that TS = {T1, T2, T3, ..., T n}, TS is a list set consisting of lists of all data tables contained in the database, where each element T i Contains the following attributes: table ID of the data table, table name of the data table, number of fields of the data table, field list of the data table, creation time of the data table, list of all data pages contained in the data table, and status of the data table, wherein the status of the data table includes normal and deleted.

[0056] In a specific embodiment, the data action area list AS specifically includes:

[0057] Assume AS = {A1, A2, A3, ..., A n}, AS is a list of data scopes for all data in the database, where each element A iContains the following attributes: device number, starting address of the device, and size of the data area of ​​the device.

[0058] In a specific embodiment, the data page list set PS specifically includes:

[0059] Assume PS = {P1, P2, P3, ..., P n}, PS is a list of all data pages contained in the data table, each element P i Contains the following attributes: the page number of the current data page, the table ID to which the current data page belongs, the number of data page records of the current data page, and a list of all records of the current data page.

[0060] In a specific embodiment, the record list set RS specifically includes:

[0061] Assume RS = {R1, R2, R3, …, R n}, RS is the set of all record lists contained in a data page, each element R i Contains the following attributes: record number, length, record data, and record status, where the record status includes normal and deleted.

[0062] According to a second aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a computer processor, the above method is implemented.

[0063] According to a third aspect of the present invention, a Sybase ASE database deleted data recovery device is provided, the device comprising:

[0064] Database list acquisition module: configured to parse and restore the system data of the Master database, obtain the list containing the respective attributes corresponding to each database, and form a database list set DS;

[0065] Data table list acquisition module: configured to traverse the elements in the database list set DS, parse and restore the database in sequence according to the list corresponding to the database, thereby extracting the list of all data tables contained in the database to form a list set TS, and at the same time obtain the data action area list AS of the database;

[0066] Data page list acquisition module: configured to scan the database action area according to the data action area list AS, and read the data page node depth index through the table IDs of all data tables contained in the database, and obtain all data page lists contained in each data table, thereby forming a data page list set PS;

[0067] Record list acquisition module: configured to traverse the data page list set PS, parse and restore the data pages in the PS according to the index list of the elements in the PS, thereby sequentially parsing and restoring each data table, obtaining the record list of each data table, and forming all the record lists into a record list set RS;

[0068] Deleted record recovery module: configured to parse and recover user table records to obtain the record list set RS of all data pages, then read the index list of elements in the PS to obtain the record index address, and parse the records of the record list set RS of all data pages starting from the record index address according to the system table record format, thereby recovering the deleted records.

[0069] The present invention parses and recovers the system data of the Master database, obtains the list containing the respective attributes corresponding to each database, and forms a database list set DS; extracts the list of all data tables contained in the database to form a list set TS; reads the data page node depth index through the table ID of all data tables contained in the database, obtains the list of all data pages contained in each data table, and thus forms a data page list set PS; parses and recovers the data pages in PS according to the index list of the elements in PS, thereby successively parsing and recovering each data table, and forming a record list set RS with all record lists; reads the index list of the elements in PS to obtain the record index address, and parses the record list set RS of all data pages starting from the record index address, according to the system table record format, and thus recovers the deleted records. The invention innovatively designs a method for recovering deleted data of the Sybase ASE database, so that the deleted data of the Sybase ASE database can be smoothly recovered. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] The accompanying drawings are included to provide a further understanding of the embodiments and are incorporated into and constitute a part of this specification. The accompanying drawings illustrate the embodiments and together with the description are used to explain the principles of the present invention. Other embodiments and many expected advantages of the embodiments will be readily appreciated as they become better understood by reference to the following detailed description. Other features, objects and advantages of the present application will become more apparent by reading the detailed description of the non-limiting embodiments made with reference to the following drawings:

[0071] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0072] Figure 2 It is a flow chart of a method for recovering deleted data from a Sybase ASE database according to an embodiment of the present invention;

[0073] Figure 3It is a schematic diagram of the relationship between the device and the database of a specific embodiment of the present invention;

[0074] Figure 4 is a schematic diagram of a data page structure of a specific embodiment of the present invention;

[0075] Figure 5 It is a schematic diagram of a system table record structure of a specific embodiment of the present invention;

[0076] Figure 6 It is a schematic diagram of a user table record structure of a specific embodiment of the present invention;

[0077] Figure 7 is a schematic diagram of deleting records at the end of a data page according to a specific embodiment of the present invention;

[0078] Figure 8 It is a table testtable created in the master database of a specific embodiment of the present invention;

[0079] Fig. 9 It is a normal record obtained by the present invention from the table testtable created in the master database of a specific embodiment of the present invention;

[0080] Fig.10 It is a deleted record restored by the present invention from the table testtable created in the master database of a specific embodiment of the present invention;

[0081] Fig.11 This is a recovery prompt diagram after executing drop table testable according to a specific embodiment of the present invention;

[0082] Fig.12 It is a deleted record that is recovered after executing drop table testable in a specific embodiment of the present invention;

[0083] Fig.13 It is a recovery result of a deleted database according to a specific embodiment of the present invention;

[0084] Fig.14 It is a framework diagram of a Sybase ASE database deleted data recovery device according to an embodiment of the present invention;

[0085] Fig.15 It is a structural diagram of a computer system suitable for implementing an electronic device of an embodiment of the present application. DETAILED DESCRIPTION

[0086] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It should also be noted that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.

[0087] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0088] Figure 1 An exemplary system architecture 100 is shown to which a method for recovering deleted data of a Sybase ASE database according to an embodiment of the present application can be applied.

[0089] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0090] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various applications can be installed on terminal devices 101, 102, 103, such as data processing applications, data visualization applications, web browser applications, etc.

[0091] Terminal devices 101, 102, 103 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, etc. When terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or they can be implemented as a single software or software module. No specific limitation is made here.

[0092] The server 105 may be a server that provides various services, such as a background information processing server that provides support for the database list displayed on the terminal devices 101, 102, and 103. The background information processing server may process the acquired record index address and generate a processing result (such as deleting the record).

[0093] It should be noted that the method provided in the embodiment of the present application can be executed by the server 105, and can also be executed by the terminal devices 101, 102, 103. The corresponding device is generally set in the server 105, and can also be set in the terminal devices 101, 102, 103.

[0094] It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.

[0095] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0096] According to an embodiment of the present invention, a method for recovering deleted data from a Sybase ASE database is provided. Figure 2 FIG. 1 is a flow chart showing a method for recovering deleted data from a Sybase ASE database according to an embodiment of the present invention. Figure 2 As shown, the method comprises the following steps:

[0097] S1: parse and restore the system data of the Master database, obtain the list containing the respective attributes corresponding to each database, and form a database list set DS;

[0098] S2: traverse the elements in the database list set DS, parse and restore the database in turn according to the list corresponding to the database, thereby extracting the list of all data tables contained in the database to form a list set TS, and at the same time obtain the data action area list AS of the database;

[0099] S3: Scan the database's action area according to the data action area list AS, and read the data page node depth index through the table IDs of all data tables contained in the database, and obtain all data page lists contained in each data table, thereby forming a data page list set PS;

[0100] S4: traverse the data page list set PS, parse and restore the data pages in the PS according to the index list of the elements in the PS, and parse and restore each data table in turn, obtain the record list of each data table, and form all the record lists into a record list set RS;

[0101] S5: Parse and restore the user table records to obtain the record list set RS of all data pages, then read the index list of the elements in the PS to obtain the record index address, and parse the records of the record list set RS of all data pages starting from the record index address according to the system table record format, so as to restore the deleted records.

[0102] In a specific embodiment, the S1 specifically includes:

[0103] S101: Read the data page size PageSize from the 56th byte of the master device header;

[0104] S102: Read the size of the system database master from the 11th byte of the master device header;

[0105] S103: Execute S3 to obtain all the data page list sets PS of each data table within the area of ​​the master database;

[0106] S104: according to the fixed table ID value of the system table sysdevices, sysdatabases, sysusages, find the data page list set PS of the data table corresponding to the fixed table ID;

[0107] S105: Execute S4 through the fixed field list and data page list of the system table, and parse the data pages in sequence to obtain all the record list sets RS;

[0108] S106: traverse the record list set RS of the sysdatabases table in sequence, obtain all database names and database IDs, associate the database ID with the sysusages table to obtain the data application area list AS, database creation time, user ID, and obtain the status of the database through the record status, thereby obtaining the database list set DS; wherein, when the record status is normal, it indicates a normal database, and when the record status is deleted, it indicates a deleted database;

[0109] S107: Execute S2 to parse and restore the database list set DS in sequence, and obtain the list set TS of each database.

[0110] In a specific embodiment, the S2 specifically includes:

[0111] S201: Set database D i is an element in the database list set DS;

[0112] S202: Take D iThe data action area list AS of the database, execute S3, and obtain all the data page list sets PS of each data table within the data action area of ​​the database;

[0113] S203: Find the corresponding table data page list through the fixed table ID value of the system table sysobjects and syscolumns;

[0114] S204: Execute S4, and parse the data pages in sequence through the fixed field lists of the system tables sysobjects and syscolumns to obtain the record list set RS;

[0115] S205: traverse all the record list sets RS of the system sysobjects in sequence, take the records of the user table type; obtain the table name of the data table, the table ID of the data table, the creation time of the data table, obtain the status according to whether the record is deleted, associate syscolumns with the table ID of the data table to obtain a list of all fields of the data table, and search for the data page list set PS of the data table through the table ID, so as to obtain the list set TS;

[0116] S206: Execute S5 through the fixed field list and data page list of the system table, and parse the data pages in sequence to obtain all the record list sets RS.

[0117] In a specific embodiment, the S3 specifically includes:

[0118] S301: Set CurPageNo as the current page number, and the initial value of CurPageNo is 0; i is an element in the data action area list AS, and the initial value of i is 0;

[0119] S302: Set the initial value of offset to A i The starting address of the i size;

[0120] S303: If offset is less than size, execute S304, otherwise i is incremented by 1, and if i is less than the number of elements in the data action area list AS, jump to S302, otherwise end;

[0121] S304: From A i The data of PageSize size is read from the offset position and recorded as Buffer until A is reached. i The size of i is increased by 1 to continue reading the next data area until the end;

[0122] S305: Read the table page number PageNo from the Buffer offset 0 bytes, read the table ID from the offset 12 bytes, read the data page node depth Level from the offset 22 bytes, and read the data page node depth index ID from the offset 23 bytes;

[0123] S306: If the table ID is not equal to 0, and CurPageNo is equal to PageNo, and the node depth is equal to 0, and the index ID is equal to 0, then the data page is a valid data page and is classified into the corresponding data page list set PS by the table ID; otherwise, the data page is discarded as a non-data page;

[0124] S307: CurPageNo is incremented by 1, offset is incremented by PageSize, and then the process jumps to S302.

[0125] In a specific embodiment, the S4 specifically includes:

[0126] S401: Let T be a data table, and the number of fields in data table T be FieldCnt;

[0127] S402: The number of fixed-length fields is calculated as FixLenCnt1 through the field list of T, the total length of the fixed-length fields is FixLen, and the number of variable-length fields is VarLenCnt1;

[0128] S403: Assume that the data page list set PS is the data page list of T, P i is an element of the data page list set PS, and the initial value of i is set to 0;

[0129] S404: Read P i The index list of the data page is obtained by starting from the record index address and parsing the records according to the system table record format; if the fourth bit of the record status value Status is 1, it indicates a deleted record, and if it is 0, it indicates a normal record; thereby obtaining the record list set RS of the data page;

[0130] S405: i is increased by 1. If i is less than the number of elements in the data page list set PS, the process jumps to S404, otherwise, the process ends.

[0131] In a specific embodiment, the S5 specifically includes:

[0132] S501: Let T be a data table, and the number of fields in data table T be FieldCnt;

[0133] S502: The number of fixed-length fields is calculated as FixLenCnt1 through the field list of T, the total length of the fixed-length fields is FixLen, and the number of variable-length fields is VarCnt1;

[0134] S503: Assume that the data page list set PS is the data page list of T, P i is an element of the data page list set PS, and the initial value of i is set to 0;

[0135] S504: Read P i The number of records in the page header is RecordCnt. Read from the end of the page forward according to RecordCnt to obtain the record index address in sequence. Starting from the record index address, parse the record according to the system table record format. Thus, all normal records of the data page are obtained.

[0136] S505: Set the end position of the last normal record as offset. If there is no normal record in the data page, then set offset to the end position of the page header 32.

[0137] S506: If offset is less than PageSize-RecordCnt*2-4, then offset is incremented by 1, and the record is executed in S507; otherwise, i is incremented by 1, and if i is less than the number of elements in the data page list set PS, the process jumps to S504, otherwise, the process ends;

[0138] S507: Assuming that the data record starting from the offset position is a deleted data record, then read the variable length field number VarCnt, record sequence number RecordNo, fixed length field data FixLenData, total record length RecordLen, and variable length field index list VarLenIndexs of the record according to the record structure of the user table;

[0139] S508: If VarCnt is not equal to VarCnt1 or RecordLen is greater than or equal to PageSize, the record is invalid, and Offset is increased by 1 and the process jumps to S506;

[0140] S509: If VarCnt1 is greater than 0 and RecordLen is less than FixLen+4 or VarCnt1 is equal to 0 and RecordLen is not equal to FixLen+2, the record is invalid, and Offset is increased by 1 and the process jumps to S506;

[0141] S510: If VarCnt1 is greater than 0, the address range of each variable-length field in VarLenIndexs is not within the variable-length data range, or each address is not increasing in sequence, or the number of bytes occupied by the end address plus the variable-length field index is not equal to RecordLen, then the record is invalid, and Offset is increased by 1 and jumps to S506. Otherwise, the record is a valid deletion record, and Offset is increased by RecordLen and jumps to S506.

[0142] In a specific embodiment, the database list set DS specifically includes:

[0143] Assume that DS = {D1, D2, D3, ..., D n}, where each element D i Contains the following attributes: database ID, database name, database creation time, user ID, a list of data scopes of the data in the database, a list of all data tables contained in the database, and database status, where the database status includes normal and deleted.

[0144] In a specific embodiment, the list set TS specifically includes:

[0145] Assume that TS = {T1, T2, T3, ..., T n}, TS is a list set consisting of lists of all data tables contained in the database, where each element T i Contains the following attributes: table ID of the data table, table name of the data table, number of fields of the data table, field list of the data table, creation time of the data table, list of all data pages contained in the data table, and status of the data table, wherein the status of the data table includes normal and deleted.

[0146] In a specific embodiment, the data action area list AS specifically includes:

[0147] Assume AS = {A1, A2, A3, ..., A n}, AS is a list of data scopes for all data in the database, where each element A i Contains the following attributes: device number, starting address of the device, and size of the data area of ​​the device.

[0148] In a specific embodiment, the data page list set PS specifically includes:

[0149] Assume PS = {P1, P2, P3, ..., P n}, PS is a list of all data pages contained in the data table, each element P i Contains the following attributes: the page number of the current data page, the table ID to which the current data page belongs, the number of data page records of the current data page, and a list of all records of the current data page.

[0150] In a specific embodiment, the record list set RS specifically includes:

[0151] Assume RS = {R1, R2, R3, …, R n}, RS is the set of all record lists contained in a data page, each element R iContains the following attributes: record number, length, record data, and record status, where the record status includes normal and deleted.

[0152] The solution of the present invention is described in detail below in conjunction with the Sybase ASE database storage structure and data deletion mechanism.

[0153] The overall structure of the Sybase ASE database:

[0154] 1) Figure 3 This is a diagram of the relationship between a device and a database in a specific embodiment of the present invention; Sybase ASE database uses a device to store a database. One device can store multiple databases, and one database can also occupy multiple devices, that is, the relationship between the device and the data is many-to-many. In the Windows system, a device is a file, and the default file suffix is ​​dat;

[0155] 2) After the database instance is created, the data directory contains five default device files: master.dat, sybpcidbdev_data.dat, sybprocs.dat, sybsysdb.dat, and tempdbdev.dat. The default devices contain five default databases: master, model, sybsysdb, sybsystmprocs, and tempdb. The master database is the main database of the system and is the core database for managing and controlling user databases and maintaining the normal operation of the server. It manages the users, devices, databases of the entire instance, and the data storage of each database.

[0156] System base tables:

[0157] Sybase ASE database manages user databases and user data tables through system base tables; key system base tables mainly use sysdevices, sysdatabases, sysusages, sysobjects, and syscolumns, etc., as described below:

[0158] 1) The main function of the sysdevices table is to record the status of all devices in the database instance. It contains field information such as device name, device file path, and device number. It only works in the master database;

[0159] 2) The main function of the sysdatabases table is to record the status of all databases in the database instance; it contains field information such as database name, database id, user, creation time, etc.; it only works in the master database;

[0160] 3) The main function of the sysusages table is to record the relationship between all databases and devices in the database instance, that is, the data scope of each database. A database may correspond to multiple sysusages table records, that is, the database has multiple data scopes; it contains the database ID, the device number, the starting position in the device, the data area size, the creation time and other field information; it only works in the master database;

[0161] 4) The main function of the sysobjects table is to record all objects in the current database, etc. It contains field information such as object name, object id, user id, creation time, etc. Each database contains this system base table;

[0162] 5) The main function of the syscolumns table is to record the field information of all tables in the current database; it contains the object id, the field id of the table, whether it is allowed to be empty, the field type, the field length, the offset address of the field in the record, and other field information. If the offset address of the field in the record is greater than 0, it means that the field is fixed length and its value is the actual offset address; if it is less than 0, the field is variable length and its value indicates the order of the variable length field in the record; each database contains the system base table;

[0163] Data page structure:

[0164] A data page is the smallest storage unit for data. It consists of three parts: page header, record data area, and record index area. A data page contains two formats: system table data page and user table data page. Figure 4 Schematic diagram of a data page structure of a specific embodiment of the present invention. The specific description of the data page structure is as follows:

[0165] 1) The system table page header contains: page number (PageNo), table ID to which the page belongs (Table ID), previous page number (PrevPageNo), next page number (NextPageNo), page header flag (PageHeadFlag, the value is equal to the page footer flag), number of records contained in the page (RecordCnt), depth of the B+ tree index node where the page is located (Level, data pages must be leaf nodes, the node depth is 0), and fixed length of the record (FixLen).

[0166] 2) The system table record structure includes: record number (RecordNo), record status (Status), variable length field number (VarCnt), fixed length field data (FixLenData), total record length (RecordLen), variable length field data (VarLenData), and variable length field index list (VarLenIndexs, the offset address of the variable length field in the record). Figure 5 It is a schematic diagram of a system table record structure of a specific embodiment of the present invention.

[0167] 3) The record index area includes: the page end flag (PageEndFlag, which is equal to the PageHeadFlag value) and the record index list (RecordIndexs, which records the offset position of each record within the page).

[0168] 4) The user table page header contains: page number (PageNo), table ID to which the page belongs (Table ID), previous page number (PrevPageNo), next page number (NextPageNo), number of records contained in the page (RecordCnt), and the depth of the B+ tree index node where the page is located (Level, data pages must be leaf nodes, and the node depth is 0).

[0169] 5) The user table record structure includes: variable length field number (VarCnt), record sequence number (RecordNo), fixed length field data (FixLenData), total record length (RecordLen), variable length field data (VarLenData), variable length field index list (VarLenIndexs, record variable length field offset address within the record). Figure 6 It is a schematic diagram of a user table record structure of a specific embodiment of the present invention.

[0170] 6) The record index area contains: a variable-length field index list (VarLenIndexs, recording the offset address of the variable-length field within the record).

[0171] Recovery principle introduction:

[0172] 1) Each data page records the table ID to which the data page belongs. By scanning each page, all data pages of each table can be obtained. The system table has a fixed table ID and table structure. After parsing the system table through the table ID and table structure of the system table, all devices, databases, data area ranges of each database, and all user table information in the system table can be obtained.

[0173] 2) System tables cannot delete records directly. However, if you execute the drop table command or the drop database command, the corresponding records in the system tables will be deleted. For example, the corresponding records in the sysobjects and sysdatabases tables will be deleted. You can restore the deleted table or database by restoring the corresponding records in the system tables.

[0174] 3) After the user table data is deleted, the remaining normal records in the data page are overwritten. The corresponding record index is also cleared. If the deleted data record is at the end of the data page or truncate table is executed to delete it, the deleted data can be recovered. Figure 7 is a schematic diagram of deleting records at the end of a data page according to a specific embodiment of the present invention;

[0175] 4) If Figure 7 As shown in the figure, after the user table data is deleted, the record index is cleared and the record start position cannot be obtained through the index. The table structure matching method can be used to scan the residual data space in the page to restore the deleted records.

[0176] The following is an example for experimental testing and verification. The specific steps are as follows:

[0177] 1) Build the Sybase ASE 16 database environment.

[0178] 2) Create a table testtable in the master database and insert 16 records. Figure 8 This is the table testtable created in the master database of this embodiment.

[0179] 3) Use the method described in this article to parse the table and get 16 normal records. Fig. 9 This is a normal record obtained by the present invention for the table testtable created under the master database of this embodiment.

[0180] 4) Execute truncate table testtable to delete all records in the table, and then use the method described in the article to restore the table and recover 16 deleted records. Fig.10 It is the deleted record restored by the present invention from the table testtable created in the master database of this embodiment.

[0181] 5) Continue to execute drop table testable, and then use the method described in the article to restore the table. The deleted testtable can be restored. Fig.11 This is the recovery prompt diagram after executing drop table testable in this embodiment. After restoring testtable, the deleted records are obtained. Fig.12 The figure shows the deleted records that are recovered after executing drop table testable in this embodiment;

[0182] 6) Create a database named testdb2, and then execute drop database testdb2. You can use the method described in this article to restore the deleted testdb2 database. Fig.13 This is the recovery result of the deleted database in this embodiment.

[0183] Fig.14 The framework diagram of a Sybase ASE database deleted data recovery device according to an embodiment of the present invention is shown. The device comprises a database list acquisition module 1401, a data table list acquisition module 1402, a data page list acquisition module 1403, a record list acquisition module 1404 and a deleted record recovery module 1405.

[0184] In a specific embodiment, the database list acquisition module 1401 is configured to parse and restore the system data of the Master database, obtain a list containing respective attributes corresponding to each database, and form a database list set DS;

[0185] The data table list acquisition module 1402 is configured to traverse the elements in the database list set DS, parse and restore the database in turn according to the list corresponding to the database, thereby extracting the list of all data tables contained in the database to form a list set TS, and at the same time obtain the data action area list AS of the database;

[0186] The data page list acquisition module 1403 is configured to scan the application area of ​​the database according to the data application area list AS, and read the data page node depth index through the table IDs of all data tables contained in the database, and obtain all data page lists contained in each data table, thereby forming a data page list set PS;

[0187] The record list acquisition module 1404 is configured to traverse the data page list set PS, parse and restore the data pages in the PS according to the index list of the elements in the PS, and thus parse and restore each data table in turn, obtain the record list of each data table, and form all the record lists into a record list set RS;

[0188] The deleted record recovery module 1405 is configured to parse and recover the user table records to obtain the record list set RS of all data pages, then read the index list of the elements in the PS to obtain the record index address, and parse the records of the record list set RS of all data pages starting from the record index address according to the system table record format, thereby recovering the deleted records.

[0189] This device parses and recovers the system data of the Master database, obtains the list containing the respective attributes corresponding to each database, and forms a database list set DS; extracts the list of all data tables contained in the database to form a list set TS; reads the data page node depth index through the table ID of all data tables contained in the database, obtains the list of all data pages contained in each data table, and thus forms a data page list set PS; parses and recovers the data pages in PS according to the index list of the elements in PS, thereby successively parsing and recovering each data table, and forming a record list set RS with all record lists; reads the index list of the elements in PS to obtain the record index address, and parses the records of the record list set RS of all data pages starting from the record index address according to the system table record format, thereby recovering the deleted records. The method for recovering deleted data of the Sybase ASE database is innovatively designed, so that the deleted data of the Sybase ASE database can be successfully recovered.

[0190] Reference below Fig.15 , which shows a schematic diagram of the structure of a computer system 1500 suitable for implementing an electronic device of an embodiment of the present application. Fig.15 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0191] like Fig.15 As shown, the computer system 1500 includes a central processing unit (CPU) 1501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1502 or a program loaded from a storage part 1508 into a random access memory (RAM) 1503. In the RAM 1503, various programs and data required for the operation of the system 1500 are also stored. The CPU 1501, the ROM 1502, and the RAM 1503 are connected to each other via a bus 1504. An input / output (I / O) interface 1505 is also connected to the bus 1504.

[0192] The following components are connected to the I / O interface 1505: an input section 1506 including a keyboard, a mouse, etc.; an output section 1507 including a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section 1508 including a hard disk, etc.; and a communication section 1509 including a network interface card such as a LAN card, a modem, etc. The communication section 1509 performs communication processing via a network such as the Internet. A drive 1510 is also connected to the I / O interface 1505 as needed. A removable medium 1511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1510 as needed, so that a computer program read therefrom is installed into the storage section 1508 as needed.

[0193] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1509, and / or installed from the removable medium 1511. When the computer program is executed by the central processing unit (CPU) 1501, the above functions defined in the method of the present application are executed. It should be noted that the computer-readable storage medium described in the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device, or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable storage medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wireless, wireline, optical cable, RF, etc., or any suitable combination of the foregoing.

[0194] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0195] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0196] The modules involved in the embodiments described in the present application may be implemented by software or hardware. The units described may also be arranged in a processor, and the names of these units do not constitute limitations on the units themselves in certain circumstances.

[0197] An embodiment of the present invention further relates to a computer-readable storage medium having a computer program stored thereon, which implements the method described above when the computer program is executed by a computer processor. The computer program includes program code for executing the method shown in the flowchart. It should be noted that the computer-readable medium of the present application may be a computer-readable signal medium or a computer-readable medium or any combination of the above two.

[0198] The present invention parses and recovers the system data of the Master database, obtains the list containing the respective attributes corresponding to each database, and forms a database list set DS; extracts the list of all data tables contained in the database to form a list set TS; reads the data page node depth index through the table ID of all data tables contained in the database, obtains the list of all data pages contained in each data table, and thus forms a data page list set PS; parses and recovers the data pages in PS according to the index list of the elements in PS, thereby successively parsing and recovering each data table, and forming a record list set RS with all record lists; reads the index list of the elements in PS to obtain the record index address, and parses the record list set RS of all data pages starting from the record index address, according to the system table record format, and thus recovers the deleted records. The invention innovatively designs a method for recovering deleted data of the Sybase ASE database, so that the deleted data of the Sybase ASE database can be smoothly recovered.

[0199] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above invention concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.

Claims

1. A method for recovering deleted data from a Sybase ASE database, characterized in that: The following steps are involved: S1: parse and restore the system data of the Master database, obtain the list containing the respective attributes corresponding to each database, and form a database list set DS; S2: traverse the elements in the database list set DS, parse and restore the database in turn according to the list corresponding to the database, thereby extracting the list of all data tables contained in the database to form a list set TS, and at the same time obtain the data action area list AS of the database; S3: Scan the database's action area according to the data action area list AS, and read the data page node depth index through the table IDs of all data tables contained in the database, and obtain all data page lists contained in each data table, thereby forming a data page list set PS; S4: traverse the data page list set PS, parse and restore the data pages in the PS according to the index list of the elements in the PS, and parse and restore each data table in turn, obtain the record list of each data table, and form all the record lists into a record list set RS; S5: Parse and restore the user table records to obtain the record list set RS of all data pages, then read the index list of the elements in the PS to obtain the record index address, and parse the records of the record list set RS of all data pages starting from the record index address according to the system table record format, so as to restore the deleted records; S5 specifically includes: S501: Let T be a data table, and the number of fields in data table T be FieldCnt; S502: The number of fixed-length fields is calculated as FixLenCnt1 through the field list of T, the total length of the fixed-length fields is FixLen, and the number of variable-length fields is VarCnt1; S503: Assume that the data page list set PS is the data page list of T, P i is an element of the data page list set PS, and the initial value of i is set to 0; S504: Read P i The number of records in the page header is RecordCnt. Read from the end of the page forward according to RecordCnt to obtain the record index address in sequence. Starting from the record index address, parse the record according to the system table record format. Thus, all normal records of the data page are obtained. S505: Set the end position of the last normal record as offset. If there is no normal record in the data page, then set offset to the end position of the page header 32. S506: If offset is less than PageSize-RecordCnt*2-4, then offset is incremented by 1 and the record is executed in S507; otherwise, i is incremented by 1, and if i is less than the number of elements in the data page list set PS, the process jumps to S504, otherwise, the process ends; S507: Assuming that the data record starting from the offset position is a deleted data record, then read the variable length field number VarCnt, record sequence number RecordNo, fixed length field data FixLenData, total record length RecordLen, and variable length field index list VarLenIndexs of the record according to the record structure of the user table; S508: If VarCnt is not equal to VarCnt1 or RecordLen is greater than or equal to PageSize, the record is invalid, and Offset is increased by 1 and the process jumps to S506; S509: If VarCnt1 is greater than 0 and RecordLen is less than FixLen+4 or VarCnt1 is equal to 0 and RecordLen is not equal to FixLen+2, the record is invalid, and Offset is increased by 1 and the process jumps to S506; S510: If VarCnt1 is greater than 0, the address range of each variable-length field in VarLenIndexs is not within the variable-length data range, or each address is not increasing in sequence, or the number of bytes occupied by the end address plus the variable-length field index is not equal to RecordLen, then the record is invalid, and Offset is increased by 1 and jumps to S506. Otherwise, the record is a valid deletion record, and Offset is increased by RecordLen and jumps to S506.

2. The method according to claim 1, characterized in that The S1 specifically includes: S101: Read the data page size PageSize from the 56th byte of the master device header; S102: Read the size of the system database master from the 11th byte of the master device header; S103: Execute S3 to obtain all the data page list sets PS of each data table within the area of ​​the master database; S104: according to the fixed table ID value of the system table sysdevices, sysdatabases, sysusages, find the data page list set PS of the data table corresponding to the fixed table ID; S105: Execute S4 through the fixed field list and data page list of the system table, and parse the data pages in sequence to obtain all the record list sets RS; S106: traverse the record list set RS of the sysdatabases table in sequence, obtain all database names and database IDs, associate the database ID with the sysusages table to obtain the data application area list AS, database creation time, user ID, and obtain the status of the database through the record status, thereby obtaining the database list set DS; wherein, when the record status is normal, it indicates a normal database, and when the record status is deleted, it indicates a deleted database; S107: Execute S2 to parse and restore the database list set DS in sequence, and obtain the list set TS of each database.

3. The method according to claim 1, characterized in that The S2 specifically includes: S201: Set database D i is an element in the database list set DS; S202: Take D i The data action area list AS of the database, execute S3, and obtain all the data page list sets PS of each data table within the data action area of ​​the database; S203: Find the corresponding table data page list through the fixed table ID value of the system table sysobjects and syscolumns; S204: Execute S4, and parse the data pages in sequence through the fixed field lists of the system tables sysobjects and syscolumns to obtain the record list set RS; S205: traverse all the record list sets RS of the system sysobjects in sequence, take the records of the user table type; obtain the table name of the data table, the table ID of the data table, the creation time of the data table, obtain the status according to whether the record is deleted, associate syscolumns with the table ID of the data table to obtain a list of all fields of the data table, and search for the data page list set PS of the data table through the table ID, so as to obtain the list set TS; S206: Execute S5 through the fixed field list and data page list of the system table, and parse the data pages in sequence to obtain all the record list sets RS.

4. The method according to claim 1, characterized in that: The S3 specifically includes: S301: Set CurPageNo as the current page number, and the initial value of CurPageNo is 0; i is an element in the data action area list AS, and the initial value of i is 0; S302: Set the initial value of offset to A i The starting address of the i size; S303: If offset is less than size, execute S304, otherwise i is incremented by 1, and if i is less than the number of elements in the data action area list AS, jump to S302, otherwise end; S304: From A i The data of PageSize size is read from the offset position and recorded as Buffer until A is reached. i The size of i is increased by 1 to continue reading the next data area until the end; S305: Read the table page number PageNo from the Buffer offset 0 bytes, read the table ID from the offset 12 bytes, read the data page node depth Level from the offset 22 bytes, and read the data page node depth index ID from the offset 23 bytes; S306: If the table ID is not equal to 0, and CurPageNo is equal to PageNo, and the node depth is equal to 0, and the index ID is equal to 0, then the data page is a valid data page and is classified into the corresponding data page list set PS by the table ID; otherwise, the data page is discarded as a non-data page; S307: CurPageNo is incremented by 1, offset is incremented by PageSize, and then the process jumps to S302.

5. The method according to claim 1, characterized in that The S4 specifically includes: S401: Let T be a data table, and the number of fields in data table T be FieldCnt; S402: The number of fixed-length fields is calculated as FixLenCnt1 through the field list of T, the total length of the fixed-length fields is FixLen, and the number of variable-length fields is VarLenCnt1; S403: Assume that the data page list set PS is a data page list of T, P i is an element of the data page list set PS, and the initial value of i is set to 0; S404: Read P i The index list of the data page is obtained by starting from the record index address and parsing the records according to the system table record format; if the fourth bit of the record status value Status is 1, it indicates a deleted record, and if it is 0, it indicates a normal record; thereby obtaining the record list set RS of the data page; S405: i is increased by 1. If i is less than the number of elements in the data page list set PS, the process jumps to S404, otherwise, the process ends.

6. The method according to claim 1, characterized in that The database list set DS specifically includes: Assume that DS = {D1, D2, D3, ..., D n }, where each element D i Contains the following attributes: database ID, database name, database creation time, user ID, a list of data scopes of the data in the database, a list of all data tables contained in the database, and database status, where the database status includes normal and deleted.

7. The method according to claim 1, characterized in that The list set TS specifically includes: Assume that TS = {T1, T2, T3, ..., T n }, TS is a list set consisting of lists of all data tables contained in the database, where each element T i Contains the following attributes: table ID of the data table, table name of the data table, number of fields of the data table, field list of the data table, creation time of the data table, list of all data pages contained in the data table, and status of the data table, wherein the status of the data table includes normal and deleted.

8. The method according to claim 1, characterized in that The data action area list AS specifically includes: Assume AS = {A1, A2, A3, ..., A n }, AS is a list of data scopes for all data in the database, where each element A i Contains the following attributes: device number, starting address of the device, and size of the data area of ​​the device.

9. The method according to claim 1, characterized in that: The data page list set PS specifically includes: Assume PS = {P1, P2, P3, ..., P n }, PS is a list of all data pages contained in the data table, each element P i Contains the following attributes: the page number of the current data page, the table ID to which the current data page belongs, the number of data page records of the current data page, and a list of all records of the current data page.

10. The method according to claim 1, characterized in that The record list set RS specifically includes: Assume RS = {R1, R2, R3, …, R n }, RS is the set of all record lists contained in a data page, each element R i Contains the following attributes: record number, length, record data, and record status, where the record status includes normal and deleted.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a computer processor, the method according to any one of claims 1 to 10 is implemented.

12. A Sybase ASE database deleted data recovery device, characterized in that: include: Database list acquisition module: configured to parse and restore the system data of the Master database, obtain the list containing the respective attributes corresponding to each database, and form a database list set DS; Data table list acquisition module: configured to traverse the elements in the database list set DS, parse and restore the database in sequence according to the list corresponding to the database, thereby extracting the list of all data tables contained in the database to form a list set TS, and at the same time obtain the data action area list AS of the database; Data page list acquisition module: configured to scan the database action area according to the data action area list AS, and read the data page node depth index through the table IDs of all data tables contained in the database, and obtain all data page lists contained in each data table, thereby forming a data page list set PS; Record list acquisition module: configured to traverse the data page list set PS, parse and restore the data pages in the PS according to the index list of the elements in the PS, thereby sequentially parsing and restoring each data table, obtaining the record list of each data table, and forming all the record lists into a record list set RS; Deleted record recovery module: configured to parse and recover user table records to obtain the record list set RS of all data pages, then read the index list of elements in the PS to obtain the record index address, and parse the record list set RS of all data pages starting from the record index address according to the system table record format, so as to recover the deleted records, specifically including: S501: Let T be a data table, and the number of fields in data table T be FieldCnt; S502: The number of fixed-length fields is calculated as FixLenCnt1 through the field list of T, the total length of the fixed-length fields is FixLen, and the number of variable-length fields is VarCnt1; S503: Assume that the data page list set PS is the data page list of T, P i is an element of the data page list set PS, and the initial value of i is set to 0; S504: Read P i The number of records in the page header is RecordCnt. Read from the end of the page forward according to RecordCnt to obtain the record index address in sequence. Starting from the record index address, parse the record according to the system table record format. Thus, all normal records of the data page are obtained. S505: Set the end position of the last normal record as offset. If there is no normal record in the data page, then set offset to the end position of the page header 32. S506: If offset is less than PageSize-RecordCnt*2-4, then offset is incremented by 1 and the record is executed in S507; otherwise, i is incremented by 1, and if i is less than the number of elements in the data page list set PS, the process jumps to S504, otherwise, the process ends; S507: Assuming that the data record starting from the offset position is a deleted data record, then read the variable length field number VarCnt, record sequence number RecordNo, fixed length field data FixLenData, total record length RecordLen, and variable length field index list VarLenIndexs of the record according to the record structure of the user table; S508: If VarCnt is not equal to VarCnt1 or RecordLen is greater than or equal to PageSize, the record is invalid, and Offset is increased by 1 and the process jumps to S506; S509: If VarCnt1 is greater than 0 and RecordLen is less than FixLen+4 or VarCnt1 is equal to 0 and RecordLen is not equal to FixLen+2, the record is invalid, and Offset is increased by 1 and the process jumps to S506; S510: If VarCnt1 is greater than 0, the address range of each variable-length field in VarLenIndexs is not within the variable-length data range, or each address is not increasing in sequence, or the number of bytes occupied by the end address plus the variable-length field index is not equal to RecordLen, then the record is invalid, and Offset is increased by 1 and jumps to S506. Otherwise, the record is a valid deletion record, and Offset is increased by RecordLen and jumps to S506.

Citation Information

Patent Citations

  • Data recovery method and device and Android equipment

    CN106155832A

  • A fragment data recovery method based on an ACCESS sample database

    CN109710462A