Extracts the required DDL statements to reproduce the database objects of a production database on a test database. This tool can also generate the required UPDATE statements used to replicate the statistics on the objects in a test database, as well as the update database configuration and update database manager configuration parameters and the db2set statements so that the registry variables and configuration parameter settings on the test database match those of the production database.
It is often advantageous to have a test system contain a subset of the production system's data. However, access plans selected for such a test system are not necessarily the same as those that would be selected for the production system. Both the catalog statistics and the configuration parameters for the test system must be updated to match those of the production system. Using this tool makes it possible to create a test database where access plans are similar to those that would be used on the production system.
Authorization
SELECT privilege on the system catalogs.
Required Connection
None. This command establishes a database connection.
Command Syntax
>>-db2look---d--DBname----+--------------+----------------------> '--u--Creator--' >-----+-------------------------------------------------+-------> '-+----+--+----+--+----+--+----+--+----+--+----+--' '--s-' '--g-' '--a-' '--h-' '--r-' '--c-' >-----+---------------------------------------------------------------------------------------------------------------------------------+> '-+----+---o--Fname--+-------------------+---+-------------------+---+---------------------------------------------------------+--' '--p-' '--e--+----------+--' '--m--+----------+--' '-+----+--+----+--+-----------+--+-------------+--+----+--' '--t Tname-' '--t Tname-' '--l-' '--x-' '--i userid-' '--w password-' '--f-' >--------------------------------------------------------------><
Command Parameters
If DBname is an OS/390 database then the db2look output is limited to the following:
Notes:
Notes:
Note: | If neither -u nor -a is specified, the environment variable USER is used. On UNIX based systems, this variable does not have to be explicitly set; on Windows NT, however, there is no default value for the USER environment variable: on this platform, a user variable in the SYSTEM variables must be set, or a set USER=<username> must be issued for the session. |
Note: | The DDL generated by db2look can be used to recreate user defined functions successfully. However, the user source code that a particular user defined function references (the EXTERNAL NAME clause, for example) must be available in order for the user defined function to be usable. |
Note: | Only configuration parameters and registry variables that affect the DB2 query optimizer are extracted. |
Examples
Generate the DDL statements for objects created by user walid in database DEPARTMENT. The db2look output is sent to file db2look.sql:
db2look -d department -u walid -e -o db2look.sql
Generate the UPDATE statements to replicate the statistics for the tables and indexes created by user walid in database DEPARTMENT. The output is sent to file db2look.sql:
db2look -d department -u walid -m -o db2look.sql
Generate both the DDL statements for the objects created by user walid and the UPDATE statements to replicate the statistics on the tables and indexes created by the same user. The db2look output is sent to file db2look.sql:
db2look -d department -u walid -e -m -o db2look.sql
Generate the DDL statements for objects created by all users in the database DEPARTMENT. The db2look output is sent to file db2look.sql:
db2look -d department -a -e -o db2look.sql
Generate the DDL statements for all user defined nodegroups, buffer pools and table spaces. The db2look output is sent to file db2look.sql:
db2look -d department -l -o db2look.sql
Generate the UPDATE statements for the database and database manager configuration parameters, as well as the db2set statements for the registry variables in database DEPARTMENT. The db2look output is sent to file db2look.sql:
db2look -d department -f -o db2look.sql
Generate the DDL for all objects in database DEPARTMENT, the UPDATE statements to replicate the statistics on all tables and indexes in database DEPARTMENT, the GRANT authorization statements, the UPDATE statements for the database and database manager configuration parameters, the db2set statements for the registry variables, and the DDL for all user defined nodegroups, buffer pools and table spaces in database DEPARTMENT. The output is sent to file db2look.sql.
db2look -d department -a -e -m -l -x -f -o db2look.sql