Backup, restoration, migration systems of a database5642505Abstract This invention provides an easy backup, restoration and migration method of a database system. The command interpreter receives a backup request and the controller identifies the backup object in the backup request by referring to the definition. The backup-migrate-restore-procedure generator generates a backup procedure of the backup object identified by the controller by referring to the definition. The controller converts the backup object to a command form of SQL in accordance with the procedure generated by the backup-migrate-restore-procedure generator and stores in the storage medium. The stored data are the replace information, definition, dependence information, data, journal and program. Restoration of the system and migration of the database to another system is enable by inputting such data. Backup, migration and restoration of a system is able to be made in an identical apparatus. Furthermore, since a command form of SQL is used, a special means is unnecessary for migration and restoration. Claims What is claimed is: Description BACKGROUND OF THE INVENTION
______________________________________
Operation assignment =
BACKUP: backup operation
RESTORE: installation
operation in a restoring or
migrating location
A list of objects =
object, object,....
Objects = user name (interpreted as an
abbreviation to specify all the
belongings of the user)
schema name (interpreted as all
the tables under the schema are
specified)
schema name.table name
(interpreted as the table is
specified)
privilege name
program name
Object type assignment =
D: data
C: catalog
P: program
combination of the D, C and P
(for example, D+P, etc.)
Object range assignment =
ONLY: Only specified objects
are treated as objects.
DOWN: specified objects and all
the referred objects by the
specified objects are treated as
objects.
ALL: specified objects, all the
referred objects by the specified
objects and all the objects
referring to the specified objects
are treated as objects.
Restricted range assignment =
user name list (schemas and
tables, etc. of the users who are
not on the list are exempted.)
schema name list (schemas and
tables, etc. of the schemas which
are not on the list are exempted.)
______________________________________
A list of views which should be realized to be the real tables A list of the SQL statements in order to select and transform the data for the real tables among the real tables 2) Operation of the Controller The controller construes the request from the command interpreter and controls the whole backup, migration and restoration operations. [In case of the backup] (1) The controller sends the objects received from the command interpreter to the backup-migrate-restore-procedure generator and receives catalogs of the objects and the definition, replace information and dependence information. The catalogs of the objects are as follows: U: user catalog S: schema catalog T: real table catalog V: view catalog A: authority catalog P: program catalog RU: restricted user catalog RS: restricted schema catalog (2) When the views in the view catalog V are specified to be evaluated to be the real tables, such views are realized to be the real tables by the evaluation. In the definition and the dependence information, the corresponding information of the realized views are replaced by the information of the real tables (a CREATE VIEW statement is replaced by a CREATE TABLE statement). Then, the real tables are stored. Furthermore, the views and real tables which are referred to by only the realized views are deleted from the definition. (3) If C (catalog) is included in the object type assignment, the replace information, the definition and the dependence information are stored in the storage medium by the storage medium access unit. (4) If D (data) are included in the object type assignment, the contents of the real tables in the real table catalog T are retrieved by the database and catalog access unit and stored in the storage medium as an INSERT command by the storage medium access unit. When the real tables created by the evaluation of the views in (2) are to be stored in the storage medium, the contents of the real tables stored in (2) are stored in the storage medium. When an execution of a SQL statement is specified for the real tables to be stored in the storage medium, the SQL statement is executed by the view SQL execution unit. The result is stored in the storage medium in a form of an INSERT command. If the D (data) are included in the object type assignment, the journal is retrieved by the database and catalog access unit and stored in the storage medium by the storage medium access unit. In this case, as the journal accompanies the IDs of the real tables which were objects of operation, only the contents of the journal related to the tables in the real table catalog T are retrieved. If P (program) is included in the object type assignment, programs in the P (program) are retrieved by the program access unit and stored in the storage medium by the storage medium access unit. [In case of the restoration and migration] (1) The definition, replace information and dependence information is read out by the storage medium access unit. (2) The controller sends the objects and the dependence information received from the command interpreter to the backup-migrate-restore-procedure generator and receives the catalogs of the objects. The catalogs of the objects are as follows: U: user catalog S: schema catalog T: real table catalog V: view catalog A: authority catalog P: program catalog RU: restricted user catalog RS: restricted schema catalog (3) The command interpreter receives the replacement assignment from a user and replaces the replacement file with the received replace information. (4) If C (catalog) is included in the object type assignment, the database and catalog access unit restores and migrates the definition on the objects by replacing the definition based on the replace information. In this case, the SQL definition command such as CREATE USER statements, CREATE SCHEMA statements and CREATE TABLE, CREATE VIEW, GRANT statements are read out and executed in the stored order, while replacement is made based on the replace information. The statements are already stored in a consistent order in both time and space at the time of the backup. Therefore, the execution may be made in the stored order. When a view in the view catalog V is assigned to be evaluated to be a real table, a CREATE VIEW command is converted to a CREATE TABLE command and the CREATE TABLE command is executed. Further, the CREATE TABLE command is stored as a SQL statement and executed later in (5). Among the views and real tables referred to by this view, the tables which are referred to by only this view are deleted from the definition. Such tables are distinguished by tracking the tables which are dependent only on this view among the dependence information. (5) If D (data) are included in the object type assignment, the database and catalog access unit retrieves an INSERT statement which creates the content of a real table in the real table catalog T and executes the INSERT command to restore the content of the real table in the database. Furthermore, if an execution of a SQL statement is specified for the real table, the execution is made by the view SQL execution unit and the result is stored as T'. Then, the content of the real table is cleared once by the following command: DELETE * FROM table name Then, the content of the real table is replaced by the previous result by the following command: INSERT INTO table name SELECT * FROM T' The following is an example of this; For example, real table T1 and view V1 which refers to the T1 exist. The view V1 is evaluated for the real table T1 by the execution of a SQL statement. If it is found that the real table T1 is referred to only by the view V1 and not referred to by any other views by referring to the dependence information, etc., it is not necessary to store the real table T1 in the database. Therefore, the real table T1 may be deleted. In this case, T' which is the result of evaluation of the view V1 for T1 is stored once. When it is judged that the real table T1 will not be referred to by other views and other programs anymore, the real table T1 is deleted and the view V1 which is stored in the T' may be created as the real table. When only the data of t11=100 are restored among the data of the real table T1, SELECT * FROM T1 WHERE t11-100 are directly executed. Then, the original data of T1 are replaced with the result. (6) If D (data) are included in the object type assignment, the journal is retrieved from the storage medium and applied to the database. In this case, as the journal accompanies the ID of the real table which was the object of the operation, only the content of the journal related to the table in the real table catalog T is retrieved. (7) If P (program) is included in the object type assignment, the programs in the P (program) are retrieved by the program access unit and stored in the database system. When the database is migrated from a machine to another machine, all the above steps are executed. When the database is restored within the same machine, two steps described in (5) and (6) are executed. These are realized, when only D (data) are assigned in the object type assignment. When the present data are cleared and restored by assignment, the content of the database is cleared once by DELETE * FROM table name and restored. When the content of the database is migrated, the system is also able to store the content in a higher speed instead of conveying the content as a SQL command by an INSERT command. For example, the content of the data may be stored in a form of a file and restored by replacing directly in the form of the file. In this case, the DELETE statement used in the restore operation is unnecessary. Then, when operation starts, the restored application program is executed. Since the information of the SQL procedure catalog is not migrated together in this case, the accessing SQL procedure is not found in the catalog in the migrated location. Therefore, the system recompiles the concerning SQL procedure, registers the procedure as the information of the procedure catalog, and resumes execution. Consequently, the dynamic recompile function of the SQL system is utilized and the information of the procedure catalog is automatically reproduced. Sample assignments and specifications which the command interpreter receives and sample objects which the controller receives from the backup-migrate-restore-procedure generator by the assignments and the specifications are explained. For example, the assignments and the specifications which the command interpreter receives may have various combinations. The following cases are examples when the definition which is necessary for the specified application may be retrieved: a) [A case of all the necessary elements being specified] All the elements constituting the application such as the users, schemas, real tables, views, programs and privileges are specified. Then, the system generates the necessary restore order by judging the relationships and the historic execution order of the specified information automatically. b) [A case of user names being given and other elements being automatically extracted by the system] Only one or multiple user names which constitute the application are given and the schemas, real tables, views, programs and privileges which the users own are automatically extracted. The system generates the necessary restore order by judging the relationships and the historic execution order of the information. c) [A case of schema names being given and other elements being automatically extracted by the system] Only one or multiple schema names which constitute the application are given and the users who own the schemas and the real tables, views and privileges owned by the schemas are automatically extracted. The system generates the necessary restore order by judging the relationships and the historic execution order of the information. d) [A case of table names being given and other elements being automatically extracted by the system] Only one or multiple table names which constitute the application are given and the schemas which the tables belong to, the users who own the schemas and the privileges related to the tables are automatically extracted. The system generates the necessary restore order by judging the relationships and the historic execution order of the information. e) [A case of view names being given and other elements being automatically extracted by the system] Only one or multiple view names which constitute the application are given and the schemas which the views belong to, the users who own the schemas, the privileges related to the views, the views and tables which the given views refer to and the privileges assumed for the reference are automatically extracted. The system generates the necessary restore order by judging the relationships and the historic execution order of the information automatically. f) [A case of program names being given and other elements being automatically extracted by the system] Only one or multiple program names which constitute the application are given and the users, schemas, real tables, views and privileges are automatically extracted. The system generates the necessary restore order by judging the relationships and the historic execution order of the information automatically. g) [A case of privilege names being given and other elements being automatically extracted by the system] Only one or multiple privilege names which constitute the application are given and the privileges and the users who grant and who receive the privileges, the real tables and views which are the objects of the privileges are automatically extracted. The system generates the necessary restore order by judging the relationships and the historic execution order of the information automatically. h) Furthermore, in the above a)-g), all the views referring to the extracted real tables and views are extracted. The schemas, users and privileges which are necessary for the creation of the views are also extracted. The system generates the necessary restore order by judging the relationships and the historic execution order of the information automatically. i) In the above a)-g) or in the combination of a)-g) and h), all the programs which refer to the extracted information are extracted. In the following, some examples of the values of the user catalog U, schema catalog S, real table catalog T, view catalog V, authority catalog A and program catalog P which are identified by the controller in reference with the definition for the assignment and the specification received in the command interpreter are described based on the sample definition of the database shown in the Related Art. The following example doesn't respond directly to the a)-i) which are described as the sample cases which are received by the command interpreter. One case or a combination of multiple cases is described. Further, in order to simplify the explanation, samples of only the list of the objects, object range assignments and restricted range assignments instead of all the assignments and the specifications received by the command interpreter are illustrated. The user catalog U, schema catalog S, view catalog V, real table catalog T, authority catalog A, program catalog P, restricted user catalog RU and restricted schema catalog RS show each value received by the controller from the backup-migrate-restore-procedure generator. Due to the assignment input in the command interpreter, the backup-migrate-restore-procedure generator finds the user catalog U, schema catalog S, real table catalog T, view catalog V, authority catalog A, program catalog P, restricted user catalog RU and restricted schema catalog RS and outputs to the controller. This procedure is described later. In the following examples, .phi. is used for the meaning of unspecified. Example 1
______________________________________
Backup of the specified real table
______________________________________
A list of objects = Suzuki, S1, S1. T1
Object range assignment =
ONLY
Restricted range assignment =
none
User catalog U = Suzuki
Schema catalog S = S1
View catalog V = .phi.
Real table catalog T =
T1
Authority catalog A = .phi.
Program catalog P = .phi.
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 2
______________________________________
Backup of the multiple specified real tables
______________________________________
A list of objects =
Suzuki, Tanaka, S1, S2, S1. T1,
S2. T2
Object range assignment =
ONLY
Restricted range assignment =
none
User catalog U = Suzuki, Tanaka
Schema catalog S =
S1, S2
View catalog V = .phi.
Real table catalog T =
T1, T2
Authority catalog A =
.phi.
Program catalog P =
.phi.
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 3
______________________________________
Backup of a view and a real table which the view refers
______________________________________
to
A list of objects =
Suzuki, S1, S1. V1, S1. T1
Object range assignment =
ONLY
Restricted range assignment =
none
User catalog U = Suzuki
Schema catalog S = S1
View catalog V = V1
Real table catalog T =
T1
Authority catalog A =
.phi.
Program catalog P =
.phi.
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 4
______________________________________
Backup of the multiple views and the real tables which the views
refer to
______________________________________
A list of objects =
Suzuki, Tanaka, S1, S2, S1. V1,
S2. V2, S1. T1, S2. T2
Object range assignment =
ONLY
Restricted range assignment =
none
User catalog U = Suzuki, Tanaka
Schema catalog S =
S1, S2
View catalog V = V1, V2
Authority catalog A =
Tanaka's SELECT privilege
for T1
Real Table catalog T =
T1, T2
Program catalog P =
.phi.
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 5 corresponds to the example 3. In the example 5, only the view name is specified and the table name which the view refers to is specified to be retrieved automatically. Example 5
______________________________________
Backup of a view and automatic backup of a related real
______________________________________
table
A list of objects = S1. V1
Object range assignment =
DOWN
Restricted range assignment =
none
User catalog U = Suzuki
Schema catalog S = S1
View catalog V = V1
Real table catalog T = T1
Authority catalog A = .phi.
Program catalog P = .phi.
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 6 corresponds to the example 4. In the example 6, only the view names are specified and the table names which the views refer to are specified to be retrieved automatically. Example 6
______________________________________
Backup of the multiple views and automatic backup of the related
real tables
______________________________________
A list of objects =
S1. V1, S2. V2
Object range assignment =
DOWN
Restricted range assignment =
none
User catalog U = Suzuki, Tanaka
Schema catalog S =
S1, S2
View catalog V = V1, V2
Real table catalog T =
T1, T2
Authority catalog A =
Tanaka's SELECT privilege
for T1
Program catalog P =
.phi.
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 7
______________________________________
Backup of a view and the tables which refer to the view
______________________________________
A list of objects =
S1. V2
Object range assignment =
DOWN
Restricted range assignment =
none
User catalog U = Suzuki, Tanaka
Schema catalog S =
S1, S2
View catalog V = V2
Real table catalog T =
T1, T2
Authority catalog A =
Tanaka's SELECT privilege
for T1
Program catalog P =
.phi.
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 8
______________________________________
Backup of the views and automatic backup of all the related
tables
______________________________________
A list of objects =
S1. V2
Object range assignment =
ALL
Restricted range assignment =
none
User catalog U = Suzuki, Tanaka
Schema catalog S =
S1, S2, S3
View catalog V = V2, V3
Real table catalog T =
T1, T2
Authority catalog A =
Tanaka's SELECT privilege
for T1
Program catalog P =
.phi.
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 9
______________________________________
Backup of the related complicated views
______________________________________
A list of objects =
V3
Object range assignment =
DOWN
Restricted range assignment =
none
User catalog U = Suzuki, Tanaka
Schema catalog S =
S1, S2. S3
View catalog V = V2, V3
Real table catalog T =
T1, T2
Authority catalog A =
Tanaka's SELECT privilege
for T1
Program catalog P =
.phi.
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 10
______________________________________
Backup of all the belongings of the user
______________________________________
A list of objects = Suzuki
Object range assignment =
DOWN
Restricted range assignment =
none
User catalog U = Suzuki
Schema catalog S = S1
View catalog V = V1
Real table catalog T = T1
Authority catalog A = .phi.
Program catalog P = .phi.
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 11
______________________________________
Backup of all the subjects under a schema
______________________________________
A list of objects = S1
Object range assignment =
DOWN
Restricted range assignment =
none
User catalog U = Suzuki
Schema catalog S = S1
View catalog V = V1
Real table catalog T = T1
Authority catalog A = .phi.
Program catalog P = .phi.
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 12
______________________________________
Backup of all the subjects under a schema and all the tables
______________________________________
A list of objects = S1, S2. T2
Object range assignment =
DOWN
Restricted range assignment =
none
User catalog U = Suzuki, Tanaka
Schema catalog S = S1, S2
View catalog V = V1
Real table catalog T = T1, T2
Authority catalog A = .phi.
Program catalog P = .phi.
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 13
______________________________________
Backup of the program and the related subjects
______________________________________
A list of objects =
PROG2
Object range assignment =
DOWN
Restricted range assignment =
none
User catalog U = Suzuki, Tanaka
Schema catalog S =
S1, S2, S3
View catalog V = V1, V2, V3
Real table catalog T =
T1, T2
Authority catalog A =
Tanaka's SELECT privilege
for T1
Program catalog P =
PROG2
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 14
______________________________________
Backup of the program and the tables
______________________________________
A list of objects =
PROG1, T1
Object range assignment =
DOWN
Restricted range assignment =
none
User catalog U = Suzuki, Tanaka
Schema catalog S =
S1, S2
View catalog V = V1, V2
Real table catalog T =
T1, T2
Authority catalog A =
Tanaka's SELECT privilege
for T1
Program catalog P =
PROG1
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 15
______________________________________
Backup of the program with restriction on schemas
______________________________________
A list of objects = PROG2
Object range assignment =
DOWN
Restricted range assignment =
S1
User catalog U = Suzuki
Schema catalog S = S1
View catalog V = V1
Real table catalog T = T1
Authority catalog A = .phi.
Program catalog P = PROG2
Restricted user catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
Example 16
______________________________________
Backup of the view with restriction on users
______________________________________
A list of objects = V3
Object range assignment =
DOWN
Restricted range assignment =
Suzuki
User catalog U = Suzuki
Schema catalog S = S1
View catalog V = V1
Real table catalog T = T1
Authority catalog A = .phi.
Program catalog P = PROG1
Restricted User catalog RU =
.phi.
Restricted schema catalog RS =
.phi.
______________________________________
FIG. 2 shows a sample content of the storage medium. In the FIG. 2, the replace information 50, the definition 60, the dependence information 80, the data 100, the journal 110 and programs 120 are shown. The replace information 50 stores replace information of user names. In this example, each replace information is shown as a temporary name starting with $. In this case, user 1 is Suzuki and user 2 is Tanaka. When the replace information is not replaced, the user 1 is restored or migrated as Suzuki, while the user 2 is restored or migrated as Tanaka. However, when the user names, Suzuki or Tanaka already exist in the migrating system, the replace information may be used to change the name of user 1 from Suzuki to Yamada, for example. Consequently, all the variables $U1 hereinafter are replaced with Yamada for installation. In the definition 60, the information to create the definition is provided in a SQL statement. The user 1 is created in the statement 61 and the user 2 is created in the statement 62. In the statement 63, the user 1 is set as the schema creator of the next statement 64. In the statement 64, the schema S1 is created as a belonging of the user 1 who is set in the statement 63. Similarly, in the statements 65-67, the schemas S2 and S3 are created for the user 2. In the statement 68, the user 1 is set as the executor of the following SQL statements. In the statement 69, the real table T1 is created. In the statement 70, it is declared that the user 2 is granted the privilege to refer to the real table T1 with grant option. In the statement 71, it is defined to create view V1 by selecting data whose value of the column t11 are 100 or bigger from the real table T1. In the statements 72-75, it is stated that the table 2 is created for the user 2, view V2 is created from the real tables T1 and T2 and view V3 is created from the view V2. The dependence information 80 shows the dependence relation which are extracted from the definition of the backuped database system. In this example, the statement 81 and 82 show that user 1 and user 2 are independent on anything. The statement 83 shows that the existence of the user 1 is necessary for the schema S1. The statements 84 and 85 show that the existence of the user 2 is necessary for the schemas S2 and S3. Consequently, the user 1 must already exist in order to create the schema 1. Similarly, the user 2 must already exist in order to create the schemas S2 and S3. The statement 86 shows that the schema S1 is necessary for the real table T1. The statement 87 shows that the schema S2 is necessary for the real table T2. The statement 88 shows that the real table T1 and the schema S1 are necessary for the view V1. The statement 89 shows that the real tables T1 and T2 and the schema S2 as well as the SELECT privilege for T1 granted from the user 1 to the user 2 are necessary for the view V2. The statement 90 shows that the view V2 and the schema S3 are necessary for the view V3. The statement 91 shows that the user 1 and user 2 and the real table T1 are necessary for the SELECT privilege for the real table T1 granted from the user 1 to the user 2. The statement 92 shows that the view V2 is necessary for the program P1. The statement 93 shows that the real table T2 is necessary for the program P2. The statement 94 shows that the views V1 and V3 are necessary for the program P3. The described dependence information is able to be extracted from the catalog of the definition as explained in the Related Art. For example, the statements 81 and 82 are able to be extracted by referring to the information of the user catalog. The statements 83-85 are able to be extracted by referring to the information of the schema catalog. The statements 86 and 87 are able to be extracted by referring to the information of the table catalog. The statements 88 and 89 are able to be extracted by referring to the information of the table catalog, view definition catalog and reference relation of view and table catalog. The statement 91 is able to be extracted by referring to the information of the authority catalog. The statements 92-94 are able to be extracted by referring to the reference relation of procedure and table. The data 100 provides the actual data in the database in an insert command of the SQL statement. The data insert command of the real table T1 101 and the data insert command of the real table T2 102 are also shown. The journal 110 stores the historic data of the journal in a normal file form. In this case, the historic information of the backup objects is extracted by referring to the ID of the table names and provided in the journal 110. For example, since the real tables T1 and T2 are backuped in this case, the historic data with the ID of real tables T1 and T2 are provided in the journal 110. Programs in normal file forms are provided in the programs 120. For example, the programs are program A, B, C and D which are in load module, and these programs are written in a general program language like COBOL, etc. In the program language, the procedure written in SQL exists in a form of source code as well as the call statement in order to call for the procedure in an executable form. In this case, the procedures P1, P2 and P3 are identified as the backup objects. The procedures P1, P2 and P3 in the definition are not stored in the executable forms. Instead, the source codes of the procedures P1, P2 and P3 in the load module A, B, C, and D in the COBOL program are stored as a part of the programs. The procedures P1, P2 and P3 in the definition are not stored in the executable forms. As described, a source program of the database language is stored in the load module corresponding to a normal program. The load module is executed in the database process system in the migrated location. Then, the database processing procedure is searched by using the ID of the database processing procedure in the catalog where the database processing procedure is to be registered in the migrated database process system. When the database processing procedure doesn't exist, the database language program in the load module is dynamically recompiled. When the database language program is registered newly in the catalog area where the database processing procedure is registered in the migrated location by using the file ID of the load module of the migrated location and a database processing procedure relative number, the execution of database process portion is resumed. In this case, the ID of the database processing procedure is the file ID of the load module which is picked out at the running time of the application in the system wherein the application is implemented, instead of the value like a counter, etc. Therefore, the identification of the database processing procedure is guaranteed even after the porting operation. A set of the file ID and the relative number is provided to the database process portion which is written in the inserted database language. The file ID is ID of the load module corresponding to the normal program portion of the concerning application program in the operation system and obtained at the running time of the database process application. The relative number is the concerning database process portion in the concerning application program. When the normal program needs database process in the running time, the catalog area in which the database processing procedure is registered is searched by using a set of the file ID of the operating system of the own load module which is obtained at the running time and the relative number of the required database process portion in the application. In this way, the required and registered database process portion is called out from the normal program portion. 3) Operation of the backup-migrate-restore-procedure generator Given object specification is interpreted as follows in order to get the object catalog. In the following, the part which is marked with (*) is possible to be identified by the information of the catalog in the database in case of the backup. In case of the restoration, it is possible to be identified by the dependence information.
______________________________________
(1) User catalog U =
.phi.: internal variables which store all
the specified users
Schema catalog S =
.phi.: internal variables which store all
the specified schemas
View catalog V =
.phi.: internal variables which store all
the specified views
Real table catalog T =
.phi.: internal variables which store all
the specified real tables
Authority catalog A =
.phi.: internal variables which store all
the specified privileges
Program catalog P =
.phi.: internal variables which store all
the specified programs
______________________________________
(2) When the followings are designated for each specified object, each object is determined as follows; In the following, symbol .orgate. is used to joint the subject written in the right side of the symbol to the set in the left side of the symbol.
______________________________________
a) When a user name is specified,
User catalog U =
user catalog U .orgate. this user
Schema catalog S =
schema catalog S .orgate. all the schemas
owned by this user
Real table catalog T =
real table catalog T .orgate. all the real
tables in the concerning schemas
(*)
View catalog V =
view catalog V .orgate. all the views in
the concerning schemas
b) When a schema name is specified,
User catalog U =
user catalog U .orgate. user who owns
the concerning schema
Schema catalog S =
schema catalog S .orgate. the concerning
schema (*)
Real table catalog T =
real table catalog T .orgate. all the real
tables in the concerning
schema (*)
View catalog V =
view catalog V .orgate. all the views in
the concerning schema
(*)
c) When a schema name.table name is specified,
Schema catalog S =
schema catalog S .orgate. schema name
which this table belongs to
(*)
If this table is a real table,
(*)
Real table catalog T =
real table catalog T .orgate. this table
If this table is a view, (*)
View catalog V =
view catalog V .orgate. this table
d) When privilege is specified,
User catalog U =
user catalog U .orgate. users who grant
the concerning privilege .orgate. users
who receive the concerning
privilege (*)
For the objects of the concerning privilege, the above c) is
executed.
Authority catalog A =
Authority catalog A .orgate. concerning
privilege
e) When a program name is specified,
c) is executed for the table which the concerning program
refers to.
Program catalog P =
program catalog P .orgate. concerning
program
______________________________________
The cases of retrieving the part which is marked with (*) from the catalog are explained later together with the explanation on the database and catalog access unit. The cases of retrieving the part which is marked with (*) from the dependence information are as follows; Example 1 The table catalog which belongs to a schema is retrieved. =views and real tables which are dependent on this schema are retrieved. In FIG. 2, it is known from the statement 86 and 88 that the table catalog belonging to S1 is T1 and V1. Example 2 The table catalog referred to by a view =views and real tables which are depended by this view are retrieved. In the FIG. 2, it is known from the dependence part in the statement 89 that the view V2 refers to T1 and T2. (3) Identifications of objects are made for each case when the object range assignment is ONLY, DOWN and ALL in the following ways. a) In case of ONLY, the specified objects are checked as follows; If the schemas which the real tables in the real table catalog T and the views in the view catalog V belong to are in the schema catalog S, If the owners of the schemas in the schema catalog S are in the user catalog U, If the views and real tables which are referred to by the views in the view catalog V are in the view catalog V and real table catalog T, If the privileges which are necessary for the creation of the view catalog V are in the authority catalog A. When the above conditions are not satisfied, an error is reported. b) In case of DOWN, the objects are identified as follows; Even though the motion is same as the motion of the backup-migrate-restore-procedure generator, the description is made herein for explanation. The following identification is made for each view v in the present view catalog V; When table t which is referred to by the view v is a view: View catalog V=view catalog V .orgate. table t This is repeated recursively by using table t as view v. When table t which is referred to by the view v is a real table: Real table catalog T =real table catalog T .orgate. table t If schemas which the view catalog V and real table catalog T belong to are not in the schema catalog S, such schemas are added to the schema catalog S. If owners of the schemas in the schema catalog S are not in the user catalog U, such user names are added to the user catalog U. Consequently, even if all the objects are not specified, the conditions in the case of a) ONLY are already satisfied and the range of the objects is identified as closed. Example 1 In case of user catalog U=Tanaka, schema catalog S=S2, view catalog V=V2 and real table catalog T=.phi., The real table T1 and T2 which are referred to by V2 are added to the real table catalog T. S1 is added to the schema catalog S and Suzuki is added to the user catalog U. Example 2 In case of user catalog U=Tanaka, schema catalog S=S3, view catalog V=V3 and real table catalog T=.phi., The view V2 which is referred to by V3 is added to the view catalog V. S2 is added to the schema catalog S. The real tables T1 and T2 which are referred to by the V2 are added to the real table catalog T. S1 is added to the schema catalog S and Suzuki is added to the user catalog U. c) In case of ALL, the objects are identified as follows; The procedure in the case of DOWN is executed. B=real table catalog T D=.phi. L:for each table t in the present B, a) If no view refers to any t, operation ends. b) If such view exists, for each view v which refers to t, Authority catalog A=authority catalog A .orgate. privilege granted to the owner of v for t View catalog V=view catalog V .orgate. v When all the tables referred to by v are in B: B=B .orgate. v D=D .orgate. V B=D, D=.phi. Back to L Described cases of DOWN and ALL are illustrated in FIG. 3. (4) The user names assigned in the restricted range assignment are included in the restricted user catalog RU(If no user is assigned, the restricted user catalog RU=.phi.). The schema names assigned in the restricted range assignment are included in the restricted schema catalog RS(If no schema is assigned, the restricted schema catalog RS=.phi.). (5) User catalog U=user catalog U .andgate. restricted user catalog RU(intersection of user catalog U and restricted user catalog RU) Schema catalog S=schema catalog S .andgate. restricted schema catalog RS(intersection of schema catalog S and restricted schema catalog RS) (6) The real tables and views which are not in the schemas in the schema catalog S are deleted from the real table catalog T and view catalog V being updated in the above. (7) In case of restoration and migration, the user catalog U, schema catalog S, view catalog V, real table catalog T, authority catalog A, restricted user catalog RU and restricted schema catalog RS are sent to the controller together with the assigned parameters. (8) In case of backup, the following procedure is executed. 1) A CREATE USER statement which creates the users identified in the user catalog U is created as the definition. The user names are created as the variables which are replaceable respectively. Sets of the variable names and the user names are stored orderly as replace information. 2) A CREATE SCHEMA statement which creates the schemas based on the identified user catalog U and identified schema catalog S is created and stored as the definition. 3) CREATE TABLE, CREATE VIEW and GRANT statements which create and define the real tables, views and privilege to access related to the above users and schemas are created and stored as the definition (details are described later). 4) Dependence relations identified in the above are stored as the dependence information. The dependence relations are distinguished as follows. User names in the user catalog U are independent. Schema names in the schema catalog S are taken as dependent on the users who own the schemas and the dependence information is generated. Real tables in the real table catalog T are taken as dependent on the schemas which the real tables belong to and the dependence information is created. Views in the view catalog V are taken as dependent on the real tables and views which are referred to by the view catalog V, related privileges and schemas which the view catalog V belongs to and the dependence information is generated. Privileges are taken as dependent on the grantors, receivers, tables in privilege object and the dependence information is created. Programs are taken as dependent on the tables which the programs refer to and the dependence information is generated. Storing procedure of the real tables, views and privileges operated by the backup-migrate-restore-procedure generator is as follows. The real tables and the views are mutually related and privileges are necessary to create a view. Therefore, a CREATE TABLE statement to create the table which the view refers to and a GRANT statement which defines the privileges assumed by the view must be executed before the view create statement is executed. Rough storing procedure of the real tables, views and privileges are as follows; (1) At first, all the concerning real tables are created. When each table is created, concerning privilege granted for the table is defined. (2) Views which refer only to the real tables created in the above (1) are created. When each view is created, concerning privilege granted for the view is defined. (3) Views which refer only to the above real tables and views are created. When each view is created, concerning privilege granted for the view is defined. (4) When no view refers to the real tables and views which are created so far, the procedure stops. In case that a GRANT statement for the privilege is created, multiple GRANT statements are created occasionally. For example, Fushimi creates table T1 and grants privilege on this table for Ando with GRANT OPTION. Then, Ando grants the privilege for Iwasaki. In this case, the GRANT statement has to be created in the order of Fushimi to Ando and Ando to Iwasaki in order to execute the statement correctly. Therefore, a procedure to create the order correctly is necessary. In the most general case where the real table catalog is obtained in the described procedure and ALL is selected as object range assignment, an sample procedure of creating a CREATE TABLE statement, a CREATE VIEW statement and a GRANT statement in a correct order is as follows. Since a CREATE USER statement and a CREATE SCHEMA statement are able to be created from the user catalog and the schema catalog S respectively, explanation is omitted here. [Input] Real table catalog T: Object table catalog [Output] A sequence of CREATE TABLE, CREATE VIEW and GRANT statements [Procedure] (1) Hash table B is emptied. B stores all the real tables and views which have created CREATE statements (2) Hash table D is emptied. D shows all the real tables and views which are possibly referred to by a view in an upper level among the views and real tables which have created CREATE statements so far. (3) For each table t in the real table catalog T, if t is not in any schema in the schema catalog S, no action is taken. if table t is in a schema in the schema catalog S, a CREATE TABLE statement for the table t is created. Table t is registered in the hash table B with the belonging schema name. Table t is registered in the hash table D with the belonging schema name. Then, a grant statement whose object is the table t is created in the following GRANT statement creation procedure. (4) This is made as a LOOP label. Hash table C is emptied. The hash table C shows all the views which refer to the views and real tables which are elements of the hash table D. Regarding on each table d in the hash table D, the following which starts with (a) is repeated for each view v which refers to the table d. a) If the view v is in a schema in the schema catalog S, the view v is registered in the hash table C. If the hash table C is empty, the hash table D is emptied and the routine goes to end. Otherwise, the hash table D is emptied. For each table c in the hash table C, the following a) and b) are repeated. For each view and table tv which the view v refers to, a) if tv is in the hash table B, continue. b) if tv is not in the hash table B, break. If all the views and real tables which are referred to by v are in the hash table B (if the above is terminated with continue), a) A CREATE VIEW statement for v is created. b) The view v is registered in the hash table B. c) The view v is registered in the hash table D. Back to LOOP label. The described procedure is further explained by using the sample shown in the FIG. 2. Hash table B, C and D are assumed to be prepared as shown in the FIG. 4. At first, table T1 is selected from schema S1 and real table T1 is created. The real table T1 is registered in the hash table B and D together with the schema name. Then, a GRANT statement is created whose object is the real table T1. So far, the definition 68, 69 and 70 shown in the FIG. 2 are created. Next, view V1 which refers to the real table T1 is registered in the hash table C. At this time, the hash table B, C and D are in the condition shown in FIG. 5. Since the hash table D is emptied and the views and the real tables (table T1, in this case) which are referred to by the view V1 registered in the hash table C are already registered in the hash table B, a CREATE statement for view V1 is created. At this moment, statement 71 shown in the FIG. 2 is created. Then, the view V1 is registered in the hash table B and D. Then, each table is in a condition shown in FIG. 6. The statement 70 in the FIG. 2 is explained later. Then, going back to the LOOP label in the earlier described procedure, the hash table C is emptied. It is checked if any view refers to table V1 in the hash table D. At this time, since no view refers to view V1, no registration is made in the hash table C. Since the hash table is empty, the loop ends. For real table T2 in the schema S2, same process is made. In FIG. 7, the real table T2 is registered in the hash table B and D together with the belonging schema name. At this moment, each table is in a condition shown in the FIG. 7. Next, a GRANT statement is created for the real table T2. However, since privilege is not granted for the real table T2, nothing is created. So far, statement 72 and 73 shown in FIG. 2 are created. Then, the hash table C is emptied. It is checked if any view refers to the real table T2 registered in the hash table D. In this case, since view V2 exists, the view V2 is registered in the hash table C. At this moment, each table is in a condition shown in FIG. 8. Then, the hash table D is emptied. It is checked if each view or real table which is referred to by the view V2 registered in the hash table C is registered in the hash table B. The view V2 refers to the real table T1 and T2 which are already registered in the hash table B. Therefore, a CREATE statement for the view V2 is created. At this moment, the statement 74 shown in the FIG. 2 is created. The view V2 is registered in the hash table B and D. Each table is in a condition shown in FIG. 9. Then, going back to the LOOP label, the hash table C is emptied. It is checked if any view refers to the table registered in the hash table D. Concerning the view V2, since the view V3 refers to the view V2, the view V3 is registered in the hash table C. At this moment, each table is in a condition shown in FIG. 10. Since the view V3 refers only to the view V2 and the view V2 is already registered in the hash table B, a CREATE statement is created for the view V3. At this moment the statement 75 in the FIG. 2 is created. Then, the view V3 is registered in the hash table B and D. At this time, each table is in a condition shown in FIG. 11. Then, going back to the loop label again, since no view refers to the view V3 and no view that should be newly registered in the hash table C exists, the hash table becomes empty. The process ends. As described, the real tables and views are able to be created consistently in this procedure. Next, procedure to create a GRANT statement is explained. Procedure of the GRANT statement creation (input: object name, owner name) (1) Hash table G is emptied. (2) A "owner name" is registered in the hash table G. (3) This is made as a LOOP label. (4) If the has table G is empty, the procedure ends here. Otherwise, hash table H is emptied. For each man g in the hash table G, a GRANT statement is created for all the privileges where the grantor is g and the object is "object name." If the privilege is WITH GRANT OPTION and the receiver is in the user catalog U, the receiver is registered in hash table H. G=H Back to the LOOP label A sample creation procedure of the GRANT statement is explained. The creation procedure of the GRANT statement is called in the process of generating storing procedure of the real tables and views. The case of creating the statement 70 which is the GRANT statement shown in FIG. 2 is explained. In the statement 70 of FIG. 2, $U1 grants $U2 a SELECT privilege. As shown in FIG. 12, the owner name, Suzuki is registered as $U1 in the hash table G at first. Then, GRANT statements are created for all the privileges owned by Suzuki. The GRANT statements are created by referring to the authority catalog in FIG. 24. The authority catalog includes a case where the system grants privilege and a case where a user grants another user privilege. Here, only the case where the user grants another user privilege is chosen and the case where the system grants privilege is ignored. In this example, the user, Suzuki grants the user, Tanaka the SELECT privilege. Therefore, the GRANT statement where the user, Suzuki grants the user, Tanaka the SELECT privilege is created. In this case, the privilege may be re-granted. Therefore, in the hash table H, the user name, Tanaka who can re-grant the privilege is registered. At this moment, condition is as shown in FIG. 13. Then, the hash table H is replaced with the hash table G. Consequently, Tanaka is registered in the hash table G as shown in FIG. 14. Privileges of Tanaka are searched from the authority catalog as described. If Tanaka grants privilege for other users, the GRANT statements are created for all the privileges. In this example, since it is not registered in the authority catalog that Tanaka grants other users privilege, the GRANT statement is not created. As described, when the user 1 is Suzuki, one GRANT statement is created. 4) Operation of the database and catalog access unit The database and catalog access unit is an apparatus to access the content of the database itself and the content of the catalog. This may be realized by setting a special interface in a database kernel 10. In case of SQL, etc, this part may also be written in the SQL. The access to the database is explained. For example, in order to retrieve the content of the specified real table T1, the following SQL statement is executed; SELECT * FROM T1 In order to add the content of the real table T1, the following SQL statement is executed; INSERT INTO T1 ((1,AAA,2), (2,bbb,4) . . . ) Since many SQL systems have interface for faster insert interface of the content of the tables, such interface may be used. For example, when the content of the magnetic tape with logic name `/DEV/MTOO` is inserted to the real table T1 as the content of the table, the following statement is executed; INSERT INTO T1 FROM/DEV/MTOO Next, the access to the catalog is explained. For example, the catalog information which is required by the backup-migrate-restore-procedure generator is obtained from the catalog by using SQL. All the schemas owned by the concerning user u SELECT schema name FROM schema information catalog WHERE owner=u Catalog of the views which refer to the table t in the schema s SELECT view name FROM reference relation of view and table WHERE referred table name=t AND referred schema name=s As described, necessary information may be obtained with a normal SQL interface by the normal SQL program. In case of restoration and migration, when the content of the catalog is restored in the object system, the restoration is made automatically by executing the definition group command of SQL as described. For example, in the migrated location
______________________________________
CREATE TABLE T1(
t11 NUMERIC[4]
t12 CHARACTER [8]
______________________________________
is executed to set the required information in the table catalog and the column catalog. A number of columns in each table in the table catalog is also restored automatically by the execution of the above command in regardless of the stored information. Or, when CREATE VIEW V1(v11,v12) AS SELECT * FROM T1 WHERE t11>100 is executed, the information of the reference relation of view and table and the column of the number of the tables in the schema, which should change when the number of tables increase in the schema, are updated. Therefore, such information is not necessary to be backuped. As described, the embodiment 1 has a characteristic in retrieving the definition related to the required application among the multiple applications developed in the database system as well as the required data and application program and generating an application package from them which is able to be migrated to another machine or system. Furthermore, the embodiment 1 has a characteristic in unnecessariness of a special catalog information access means in case of retrieving the definition by executing the readout of the catalog information in SQL if the catalog information is accessible by using SQL. Furthermore, in case of restoration, the definition in the migrating content is converted to a historically consistent sequence of commands (such as a CREATE TABLE, etc.) defining the definition and the restoration is made by executing the normal SQL definition commands in the specified order without a special system interface for the restoration. For the restoration of the data, the data are converted to a data insert command of SQL and executed at the restoration time. Since the international standard language called SQL is used, the package is able to be migrated over vendors. For example, the number of tables in the schema is automatically updated by the system in a normal way when the SQL statement of the table definition is executed orderly in the migrated location. Therefore, migration of the related information is unnecessary. Furthermore, a special interface is unnecessary. Further, the embodiment 1 has a characteristic in the ability of the installation of the package by replacing the subjects such as a storage location of the user name and data which may overlap in the migrated system. Further, the embodiment 1 has a characteristic in saving memory to store the SQL procedure by re-compiling the SQL procedure when the catalog does not accompany the procedure when the execution is made in the migrated location and registering the re-compiled result instead of storing the SQL procedure. Furthermore, the embodiment 1 has a characteristic in the ability of migrating the application program corresponding to the optimal parameter in the migrated location. Further, the data are not backuped or restored, but only the database definition and the memory area of the database definition are kept in order to save the memory area for the backup. Therefore, only the necessary frame for the application operation is installed as a package and the content of the database is accumulated in accordance with the progress of the operation of the application. Further, this procedure is applied to the conventional simple store and restore procedure of the database in order to execute the generation of a package and storing and restoration of the database as one procedure. Finally, in case of storing the journal, since a table ID is accompanied to each historic | ||||||
