Abstract:
The present invention relates to an optimization method in a database management system having the function of accessing external databases. Conventionally, whether functions contained in a query can be executed in external databases depends on a database management system having the functions, and therefore there has been a problem in that a database utilization method cannot apply to query optimization and query execution performance is reduced. To solve the above problem, a database management system having the function of accessing external databases is provided with an optimization step comprising the steps of: obtaining specification about whether to execute functions in a query in external databases; determining whether data referred to in a query is confined to one database; and determining whether a user specifies that the functions in the query are executed in external databases.

Description:
FIELD OF THE INVENTION  
         [0001]    The present invention relates to a database management system, a query method in the database management system, and a query execution program in the database management system, and more particularly to query optimization in them.  
         BACKGROUND OF THE INVENTION  
         [0002]    A conventional query optimization method, as disclosed in U.S. Pat. No. 5,590,321, includes the steps of: determining whether all data referred to in a query is contained in one external database; and determining whether functions in the query can be executed in the one external database, and when all data contained in the query is contained in one database and all the functions in the query can be evaluated in the external database, the query is executed in the external database.  
           [0003]    It is desirable that whether functions in a query can be executed or are desirably executed in external databases is decided by how users use data bases in the interest of optimization, based on users&#39; experience and knowledge such as function names, the format of data contained in the external databases, and how the functions are used in the query. However, in the prior art, whether functions contained in a query can be executed in external databases depends on a database management system having the function of accessing external databases. Consequently, query optimization as intended by users cannot be achieved and query execution performance is reduced. This has been a problem of the prior art.  
           [0004]    An object of the present invention is to provide a database management system that can apply a user-intended database utilization method to query optimization by enabling users to specify execution places of functions in a query, a query method in the database management system, and a query execution program in the database management system, and particularly to achieve query optimization in them.  
           [0005]    Another object of the present invention is to provide a query optimization method that permits users to specify execution places of functions in the query for each of types of database management systems, each of types and version of database management systems, and each of databases.  
         SUMMARY OF THE INVENTION  
         [0006]    The above object is achieved by a database management system having the function of accessing one or more external databases, comprising: a means for specifying whether functions in a query are executed in external databases; and a means for determining whether data referred in a query is confined to one external database, wherein, when a user&#39;s query is confined to the one external database and the user specifies execution in the external database, the query is processed in the external database.  
           [0007]    Further, the above object is achieved by a query method in a database management system having the function of accessing one or more external databases, the method including the steps of: obtaining specification about whether functions in a query are executed in external databases; determining whether data referred in the query is confined to one external database; and determining whether a user specifies whether functions in the query are executed in the external database.  
           [0008]    Further, the above object is achieved by the query method in the database management system, the query method including the steps of: if a query is confined to the one database and the user specifies that all functions in the query are processed in the one external database, creating an access procedure for processing the query in the one external database; and if the user specifies that functions in the query are not executed in the one external database, creating an access procedure for executing the functions in a database within the database management system having the function of accessing external databases.  
           [0009]    Further, the above object is achieved by a query method in the database management system, the query method including the step of the user defining whether functions in the query are executed in external databases.  
           [0010]    Further, the above object can be achieved by a query execution program in a database management system having the function of accessing one or more external databases, the query execution program executing the procedures for: obtaining specification about whether functions in a query are executed in external databases; determining whether data referred in the query is confined to one external database; and determining whether a user specifies that functions in the query are executed in the external database. 
       
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0011]    [0011]FIG. 1 is a diagram showing a configuration of a database management system having the function of accessing external databases of an embodiment of the present invention;  
         [0012]    [0012]FIG. 2 is a diagram showing a description example of a definition file;  
         [0013]    [0013]FIG. 3 is a diagram showing a configuration of a function execution evaluation table;  
         [0014]    [0014]FIG. 4 is a diagram showing a configuration of a dictionary table;  
         [0015]    [0015]FIG. 5 is a diagram showing an example of processing performed in the definition information acquisition step  103 ;  
         [0016]    [0016]FIG. 6 is a diagram showing an example of processing performed in the optimization processing step  105 ;  
         [0017]    [0017]FIG. 7 is a diagram showing an example of processing performed in the query execution evaluation step  603 ;  
         [0018]    [0018]FIG. 8 is a diagram showing an example of processing performed in the definition information acquisition step  704 ;  
         [0019]    [0019]FIG. 9 shows a query example;  
         [0020]    [0020]FIG. 10 is a diagram showing an example of codes showing an access procedure created for a query; and  
         [0021]    [0021]FIG. 11 is a diagram showing an example of codes showing an access procedure created for a query in the case where functions of the present invention are not provided. 
     
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS  
       [0022]    Hereinafter, embodiments of the present invention will be described using FIGS.  1  to  11 . FIG. 1 shows the configuration of a database management system of an embodiment of the present invention that has the function of accessing external databases. The database management system having the function of accessing the external database comprises: a client  101  making a query; a database management system  102  having the function of accessing external databases that accepts and executes a query from the client  101 ; database servers  108   a  and  108   b  that include database management systems  109   a  and  109   b  managing databases  110   a  and  110   b,  respectively; a network  107  connecting the client  101  and the database servers  108   a  and  108   b;  and an internal database  112 . The database management system  102  having the function of accessing external databases includes; a definition information acquisition step  103  that reads a definition file  106  describing execution places of functions in a query, and creates a function execution evaluation table  104 ; a dictionary table III storing information of an external database management system used in the database management system  102  having the function of accessing external databases and table definition information; and an optimization processing step  105  that optimizes a query entered from the client  101  by referring to the dictionary table  111  and the function execution evaluation table  104 .  
         [0023]    In FIG. 1, the client  101 , the database management system  102  having the function of accessing external databases, and the database management systems  109  exist in machines different from each other, and are connected over the network  107 . However, the client  101 , the database management system  102  having the function of accessing external databases, and the database management systems  109  may be disposed in an identical machine. In this case, the network  107  is unnecessary.  
         [0024]    [0024]FIG. 2 shows a description example of definition information described in the definition file  106 . A user creates a definition file  106 , based on knowledge about the operation of external database management systems. That is, a method of user-intended optimization is defined here. Next, the structure of the definition file  106  will be described. The definition file  106  comprises; a record  201  indicating whether the definition file contains a definition for each of types of database management systems, a definition for each of types and versions of database management systems, or a definition for each of databases; and a record  202  describing whether functions in a query can be executed in external databases. In an example of FIG. 2, a definition file  106   a  has a record  201   a  with the value of dbms=DBX 1 , which indicates that contents described in the definition file  106   a  are effective for database management systems whose type is DBX 1 . A definition file  106   b  has a record  201   b  with the value of dbms=DBX 1 , ver=5.0, which indicates that the definition file  106   b  is effective for version 5 of database management systems whose type is DBX 1 . A definition file  106   c  has a record  201   c  with the value of fs=db01, which indicates that a definition described in the definition file  106   c  is effective for an external database db01.  
         [0025]    [0025]FIG. 3 shows a structure of the function execution evaluation table  104 . The function execution evaluation table  104  has: a pointer  301  to definition information  309   a  for each of types of database management systems; a pointer  302  to definition information  309   b  for each of types and versions of database management systems; and a pointer  303  to definition information  309   c  for each of external databases. Each of the definition information  309   a,    309   b  and  309   c  consists of; an area  304  for storing the type of a database management system; an area  305  for storing a version; an area  306  for storing an external database name; an area  307  for storing a pointer to other definition information; and a record  308  for storing a function name in a query and a value indicating whether that function can be executed in an external database. The record  308  further consists of an area  310  for storing a function name and an area  311  for storing a value. By a step shown in FIG. 3, the contents defined in the definition file  106  of FIG. 2 can be included in the function execution evaluation table  104  of the database management system  102  of FIG. 1. As a result, a method of user-intended optimization can be included in the database management system  102 .  
         [0026]    [0026]FIG. 4 shows a table structure of a dictionary table  111  to store the definitions of external databases and table definitions, used in the database management system  102  of FIG. 1 having the function of accessing external databases. The dictionary table  111  consists of a field  401  for storing a column name; a field  402  for storing a table name; a field  403  for storing an external database name; a field  404  for storing the type of a database management system managing external databases; and a field  405  for storing the version of the database management system.  
         [0027]    [0027]FIG. 5 shows an example of processing performed in the definition information acquisition step  103 . In this processing, the following processing is performed for all definition files  106 . First, a record  201  described in the definition file  106  is obtained (step  501 ). Next, definition information  309  is created and the value of the record  201  is set in the definition information  309 . If the record  201  indicates the type and version of a database management system (the case of  106   a  in FIG. 2), the type of a database management system specified in the record  201  is stored in the field  304  for storing the type of a database management system. If the record  201  indicates the type and version of a database management system (the case of  106   b  in FIG. 2), the type of a database management system specified in the record  201  in the field  304  for storing the type of a database management system, and the version of the database management system specified in the record  201  is stored in the field  305  for storing the version of a database management system. If the record  201  indicates the name of an external database (the case of  106   c  in FIG. 2), the name of an external database specified in the record  201  is stored in the field  306  for storing an external database name (step  502 ).  
         [0028]    Thereafter, the following processing is repeatedly performed for each of records  202  of the definition file  106  currently processed (steps  503   a,    503   b ). First, a record  308  representing an execution destination for each query function is created within the definition information  309 . Next, a value described on the left side of a colon (:) of record  202  is stored in the function name area  310  of record  308 , and a value described on the right side is stored in the setting value area  311  of record  308  (step  504 ).  
         [0029]    After processing of step  504  is completed for all records  202  of the definition file  106  currently processed, the created definition information  309  is pointed to from the field  301  of the function execution evaluation table if the record  201  indicates the type of a database management system, from the field  302  of the function execution evaluation table if the record  201  indicates the type and version of a database management system, and from the field  303  of the function execution evaluation table if the record  201  indicates the name of an external database. If definition information  309  is already pointed to from the field  301 ,  302 , or  303 , the next definition information  309  is pointed to from the next pointer field  307  of definition information  309  pointed to.  
         [0030]    [0030]FIG. 6 shows an example of processing performed in the optimization processing step  105 . First, using the definition information acquisition step  103 , a definition file  106  is set in the function execution evaluation table  104  (step  601 ). If a query is inputted from the client  101  (step  602 ), for the inputted query, it is judged whether the number of external databases contained in the query is one and all functions contained in the query are specified to be executed in external servers (step  603 ). If step  603  is satisfied, codes are created to execute the query inputted in step  601  in an external database (step  604 ), and the query is executed in the external database (step  605 ). If not so, functions specified to be executed in external databases are executed in the external databases, and for other functions, codes are created to get data into the local system  102  for execution (step  606 ). The functions specified to be executed in external databases are executed in the external databases, results are stored in the internal database  112 , functions inexecutable in external databases are executed, and results are obtained (step  607 ).  
         [0031]    [0031]FIG. 7 shows an example of processing performed in the query execution evaluation step  603 . The number of external servers contained in a query is initialized to 0 (step  701 ). Next, for each of functions in the query, the following processing is repeated (steps  702   a,    702   b ).  
         [0032]    A query example of FIG. 9 will be described. A query of FIG. 9 is to obtain results of coupling results of searching table T 1  with search condition:length(T 1 .c 1 )=10 and results of searching table T 2  with search condition:length(T 2 .c 2 )&gt;15, by condition T 2 .c 2 &gt;T 1 .c 1 . The query search condition functions  902   b  (=) and  902   e  (&gt;) are defined in the definition file  106  of FIG. 2 so as to be executed in an external database management system DBX 1 . A function  902   a  (length) is defined so as to be executed in the external database db01 (the definition file  106   c  of FIG. 2). On the other hand, length of a function  902   d  is defined so as not to be executed in external databases (the definition file  106   b  of FIG. 2).  
         [0033]    If the contents of the query are as shown in FIG. 9, it is determined whether functions contained in the function  902   a  are specified to be executable in external databases in  309  of FIG. 3. In this case, only column T 1 .c 1  is contained in the length function  902   a,  but since columns are not a function, it is judged that the function  902   a  does not contain functions marked as inexecutable in external servers (step  708 ).  
         [0034]    Next, it is judged whether data contained in a function is confined to one external database. This is performed by consulting the dictionary table  111  and counting up the number of external databases to which column specifications contained in the function belong (step  703 ). If the function extends to plural external databases, it is marked as inexecutable in external servers and the function is judged (step  706 ). If the function is confined to one external database, definition information  309  provided for each of external databases of destinations to execute the function, each of the types and versions of database management systems managing the external databases, and each of the types of the database management systems is obtained from the function execution evaluation table  104  (step  705 ). It is judged whether the function is specified to be executed in external servers (step  705 ). If the function is defined as executable in definition information  309  for each of external databases (in the case where a record  308  having the name of the function in a function name field  310  exists and the value of a setting value field  311  of the record  308  is YES), it is judged that the function is specified to be executed in external databases. On the other hand, if the value of the setting value field  311  of the record  308  is NO, it is judged that the function is not specified to be executed in external databases. If a record  308  having the name of the function in the function name field  310  does not exist in the definition information  309  for each of external databases, whether the function is specified to be executable in external databases is judged using the definition information  309  for each of database management systems and versions thereof, obtained in step  704 . If a record  308  having the name of the function in the function name field  310  does not exist in the definition information  309  for each of the types and versions of database management systems, whether the function is specified to be executable in external databases is judged using the definition information  309  for each of database management systems, obtained in step  704 . If a record  308  having the name of the function in the function name field  310  does not exist in the definition information  309  for each of the types of database management systems, whether the function is specified to be executable in external databases is judged (step  705 ). Thereafter, external servers in the function and external databases that occurred previously are compared, and if they differ, the number of external servers contained in the query is increased by the number of the different databases (step  707 ).  
         [0035]    [0035]FIG. 8 shows an example of processing performed in step  704  for obtaining definition information  309  of external databases of function execution destination. From the dictionary table  111 , an external database name to which columns to obtain definition information belong, and the type and version of a database management system managing the database are obtained (step  801 ). Next, for each of definition information  309  chained from the pointer  303  of the function execution evaluation table  104 , the external database name obtained in step  801  and the value of an external database name field  306  of the definition information  309  are compared (step  802 ). If the comparison gives an equal result, the definition information  309  is marked as information to be obtained (step  805 ). Next, for each of definition information  309  chained from the pointer  302  of the function execution evaluation table  104 , the type of database management system obtained in step  801  and the value of a database management system type field  304  of the definition information  309 , and the version obtained in step  801  and the value of a version field  305  of the definition information  309  are respectively compared (step  803 ). If the comparison gives an equal result, the definition information  309  is marked as information to be obtained (step  806 ). Next, for each of definition information  390  chained from the pointer  301  of the function execution evaluation table  104 , the type of database management system obtained in step  801  and the value of the database management system type field  304  of the definition information  309  are compared (step  804 ). If the comparison gives an equal result, the definition information  309  is marked as information to be obtained (step  807 ). Last, a caller obtains the definition information  309  marked as information to be obtained in steps  805  to  807  (step  808 ).  
         [0036]    Hereinafter, a description will be made of an example of creating the function execution evaluation table  104  shown in FIG. 3 from the definition files  106   a  to  106   c  shown in FIG. 2, referring to FIG. 5. This processing is performed using the definition information acquisition step  1 O 3 . In step  501 , record  201   a  of the definition file  106   a  is read. The record  201   a  is described as dbms=DBX 1  wherein dbms= indicates that the definition file contains a definition for each of types of database management systems and the type of the database management system is DBX 1 . Accordingly, by step  502 , DBX 1  is set in a database management system type field  304   a  of definition information  309   a.  Next, in step  504 , record  202   a  is obtained, a function name= and a value (YES in the case of record  202   a ) indicating whether it is executable in an external database (in this case, an external database under a database management system DBX 1 ) are respectively set in function name field  310   a  and setting value field  311   a  of record  308   a.  In the same way, record  202   b  is also obtained to create record  308   b.  Next, in step  505 , the address of the definition information  309   a  is set in the function execution evaluation table  104 . In the case of the definition file  106   a,  since the record  201   a  is written as dbms=DBX 1 , it is judged that the definition file contains a definition for each of types of database management systems, and the address of the definition information  309   a  is set in the field  301 .  
         [0037]    In the case of the definition file  106   b,  since the record  201   b  is written as dbms=DBX 1 ,ver=5.0, DBX 1  and 5.0 are respectively set in a database management system type field  304   b  and a version field  305   b  of definition information  309   b  (steps  501 ,  502 ). Thereafter, record  202   c  is read to create record  308   c  (step  504 ). Last, since both a database management system type and version are described in the record  201   b,  it is judged that the definition file  106   b  contains a definition for each of types and versions of database management systems (DBX 1  5.0 in the case of the definition file  106   b ), and the definition information  309   b  is pointed to from the pointer  302  of the function execution evaluation table  104  (step  505 ).  
         [0038]    In the case of the definition file  106   c,  since the record  201   c  is written as fs=db01, db01 is set in an external database name field  306   c  of definition information  309   c  (steps  501 ,  502 ). Thereafter, record  202   d  is read to create record  308   d  (step  504 ). Last, since an external database name is described in record  201   c,  it is judged that the definition file  106   c  contains a definition for each of external databases (database db01 in the case of the definition file  106   c ), and the definition information  309   c  is pointed to from the pointer  303  of the function execution evaluation table  104  (step  505 ).  
         [0039]    Hereinafter, using a query  901  shown in FIG. 9 as an example, a description will be made of how it is judged as to whether it can be executed in an external server, as described in FIG. 6. Functions  902  to be judged, contained in the query  901 , are scalar function length ( 902   a ), =comparison operation ( 902   b ), &gt;comparison processing ( 902   c ), length ( 902   d ), and &gt;comparison processing ( 902   e ). The database management system  102  having the function of accessing external databases accepts the query  901  from the client  101  in step  601  and judges whether the query can be executed, in step  603 . In step  603 , a processing flow shown in FIG. 7 is performed.  
         [0040]    After the number of external databases contained in the query is initialized to 0, evaluation is made for each of functions of the query. In the case of the query example  901 , it is determined in how many external servers data contained in length function  902   a  exists (step  703 ). In this case, since the number of columns contained in the length function  902   a  is  1 , evaluation results in step  703  are Y.  
         [0041]    Next, in step  704 , definition information of an external database of execution destination of the length function  902   a  is obtained. In step  704 , a processing flow shown in FIG. 8 is performed. In step  801 , from the dictionary table  111 , an external database name to which evaluation target columns belong, and the type and version of a database management system managing the database are obtained. In this case, since column c 1  belongs to table T 1  as shown in FIG. 4, an external server name, and the type and version of a database management system of record  410   a  of the dictionary table  111  having an identical column name and table name are data to be obtained, and their values are db01, DBX1, and 5.0, respectively. Next, in step  802 , definition information  309   c  linked to a chain from the field  303  of the external server execution evaluation table  104  is referred to. The value of the external database name field  306   c  of the definition information  309   c  is db01, which is equal to the external database name obtained in step  801 . Therefore, the definition information  309   c  is returned (step  805 ). Next, definition information  309   b  pointed to from the field  302  of the external server execution evaluation table  104  is referred to. The value of the database management system type field  304   b  and the value of the version field  305   b  of the definition information  309   b  are respectively DBX1 and 5.0, which are respectively equal to the type and version of database management system obtained in step  801 . Therefore, the definition information  309   b  is marked as information to be obtained (step  806 ). Next, definition information  309   a  pointed to from the field  301  of the external server execution evaluation table  104  is referred to. The value of the database management system type field  304   a  of the definition information  309   a  is DBX1, which is equal to the database management system type obtained in step  801 . Therefore, the definition information  309   a  is obtained (step  806 ). As a result of the above processing, in step  704 , the definition information  309   c,    309   b,  and  309   a  are obtained as definition information of the external database of execution destination.  
         [0042]    Next, in step  705 , it is determined whether the length function  902   a  is specified to be executed in the external database. The definition information  309   c,    309   b,  and  309   a  are searched in that order for record  308  having length( ) as function name  310 , and the value of the setting field  311  of the first record to be found indicates whether the function is specified to be executed in the external server. In this case, record  308   d  is the first record to be found and its setting value is YES, so that it is determined that the function can be executed in the external server. Next, in step  707 , the number of external databases that have so far occurred is calculated and set to 1 because the external database occurs for the first time.  
         [0043]    Next, the same evaluation is made for function=( 902   b ). In this case, in step  708 , it is determined whether the function  902   b  contains functions marked as inexecutable in external databases. It is determined that the function contains none of them because function length ( 901   a ) can be executed in an external database. Next, in step  703 , the number of external databases contained in the function  902   b  is calculated and set to 1 because the function  902   b  contains no column and the function  902   a  contains only T 1 .c 1  as a column. Next, in step  704 , definition information of an external database in which the column T 1 .c 1  is contained is obtained. In this case, as is the case with the function  902   a,  the definition information  309   c,    309   b,  and  309   a  are returned as definition information of an external database of an execution destination. Next, in step  705 , it is determined whether the function  902   b  is specified to be executed in the external database. In this case, record  308   a  is the first record to be found and the value of the setting value field  311   a  of the record  308   a  is YES, so that it is determined that the function  902   b  can be executed in the external database. Last, in step  707 , since the column T 1 .c 1  belongs to the same external database as in the length function  902   a  processed previously, the number of external databases is not increased.  
         [0044]    Next, the same evaluation is made for function&gt;( 902   c ). In this case, in step  708 , it is determined from the setting value field  311   a  of the record  308   b  whether the function  902   c  can be executed in external databases. Since the value of the field  311   a  is YES, it is determined that the function contains no function marked as inexecutable in external databases. In step  703 , whether the number of external databases contained in the function  902   c  is one is determined by consulting the dictionary table  111 . Two columns, T 1 .c 1  and T 2 .c 2 , are contained in the function  902   c.  An external database referred to by the column T 1 .c 1  is db01 from record  410   a  and an external database referred to by the column T 2 .c 2  is db02 from record  410   b.  Since they are different, evaluation result in step  703  is N and the function  902   c  is marked as inexecutable in external databases (step  706 ). Thereafter, in step  707 , where the number of external databases is increased, the number of external databases referred to by the query is 2 because db02 occurs newly (step  707 ).  
         [0045]    Next, in step  705 , it is determined whether the length function ( 902   d ) is specified to be executed in the external database. In this case, record  308   c  is the first record to be found and the value of the setting value field  311   b  of the record  308   d  is NO, which indicates that the function cannot be executed in external servers. Therefore, the function  902   d  is marked as inexecutable in external databases. Next, in step  707 , the number of external databases that have so far occurred is calculated. Since the function contains only the column T 2 .c 2  which already occurs, the number of external databases remains set to 2.  
         [0046]    Last, the same evaluation is made for function=( 902   e ). In this case, in step  708 , it is determined whether the function  902   e  contains functions marked as inexecutable in external databases. Since the function  902   d  is already marked as inexecutable in external databases, the function  902   e  is also marked as inexecutable in external databases (step  706 ).  
         [0047]    Next, in step  603 , it is determined whether the number of databases contained in the query is one. Since the number of external databases is two, an access procedure as shown in  1003  of FIG. 10 is created (step  605 ). For the query shown in  901 , in the case where a database management system accesses a database of its own, as shown in  1001  of FIG. 10, creation is made of code ( 1001   b ) to scan table T 1  under condition length(T 1 .c 1 )=10, code ( 1001   c ) to scan table T 2  under condition length(T 2 .c 2 )&gt;15, and code  1001   a  to couple execution results of the codes  1001   b  and  1001   c  under condition T 1 .c 1 &gt;T 2 .c 2 . In step  605 , code is created for replacing the codes of scanning the tables by an SQL statement to obtain data from a table in an external database. At this time, if scanning conditions are such that execution can be made in external databases, the conditions are presented to the SQL statement, and if the scanning conditions are such that execution cannot be made in external databases, data obtained from an external database is presented with code to make selection under conditions in which execution cannot be made in the external database. In an example of the query  901 , creation is made of code  1003   b  having an SQL statement to obtain data of table T 1  from an external database under condition length (T 1 .c 1 =10), code  1003   d  to obtain data from table T 2  in an external database, code  1003   c  to select data obtained from  1003   d  under length (T 2 .c 2 )&gt;15, and code  1003   a  to couple execution results of the codes  1003   b  and  1003   c  under condition T 1 .c 1 &gt;T 2 .c 2 .  
         [0048]    If the number of external databases referred to by the query  901  is one and all functions can be executed in an external database, in step  604 , as shown in  1002 , code  1002  is created to execute the whole of the query  901  in the external database.  
         [0049]    In a database management system not having the present invention, since whether scalar function length( ) is executed in an external databases cannot be decided at user&#39;s disposal, if length( ) is incorporated in the database management system so that it cannot be executed in external databases, even if length( ) can be executed in the external database db01, conditions (functions  902   a,    902   b ) containing length( ) cannot be executed in external databases. Accordingly, codes created for the query  901 , as shown in  1101  of FIG. 11, include code  1101   c  to unconditionally obtain data from table T 1 , code  1101   b  to select data under condition length(T 1 .c 1 )=10 from the result of executing  1101   c,  code  1101   e  to unconditionally obtain data from table T 2 , code  1101   d  to select data obtained by  1101   e  under condition length(T 2 .c 2 )&gt;15, and code  1101   a  to couple the execution results of  1101   b  and  1101   d  under condition T 1 .c 1 &gt;T 2 .c 2 . As a result, the data of the table T 1  to be obtained from the external database db01 cannot be selected, reducing query performance. Since the present invention permits users to specify what functions to be executed in external databases, by specifying that the function length( ) is executed in the external database db01, the amount of data obtained from the external database db01 can be reduced, contributing to an increase in query performance.  
         [0050]    According to the present invention, since a database management system having the function of accessing external databases is provided with a means for users to be able to specify what functions in a query to execute in external databases, query optimization can be achieved as intended by users and query execution performance can be sped up.  
         [0051]    According to another aspect of the present invention, whether to execute functions in a query in external databases can be specified for each of types of database management systems, each of types and versions of database management systems, and each of external databases. Consequently, the amount of operation required for specification can be reduced. Also, focusing attention on portions specified differently depending on the versions of database management systems and external databases, common items can be picked up for definition, contributing to reduction in the amount of operation required for specification.