Run the db2look command to obtain the DDL script of the database object.

Source: Internet
Author: User

DB2's db2look command is interpreted as follows:
db2look version 8.2
db2look: generate DDL to recreate the objects defined in the database
Syntax: db2look-D dbname [-E] [-u creator] [-Z schema] [-T tname1 tname2... tnamen] [-tw tname] [-H] [-O fname] [-A]
[-M] [-C] [-R] [-L] [-x] [-XD] [-F] [-FD] [-Td x] [-noview] [-I userid] [-W Password]
[-V vname1 vname2... vnamen]
[-wrapper wrappername] [-server servername] [-nofed]

Db2look-D dbname [-u creator] [-S] [-G] [-A] [-T tname1 tname2.... tnamen]
[-P] [-O fname] [-I userid] [-W Password]
Db2look [-H]

-D: Database Name: This must be specified

-E: extract the DDL files required for database replication.
This option will generate scripts containing DDL statements
You can run this script on another database to recreate the database object.
This option can be used with the-M Option
-U: Create Program ID: If-U and-A are not specified, $ user
If the-A option is specified, the-u option is ignored.
-Z: Mode name: if both-Z and-A are specified,-Z is ignored.
The Mode name of the union is ignored.
-T: Generate Statistics for the specified table
You can specify a maximum of 30 tables.
-TW: generates DDL statements for tables whose names match the table's schema condition (wildcard ).
If the-tw option is specified, the-T option is ignored.
-V: Only DDL is generated for the view. This option is ignored when-T is specified.
-H: More Detailed Help messages
-O: redirects the output to the specified file name.
If the-O option is not specified, the output is forwarded to stdout.
-A: generate statistics for all created programs
If this option is specified, the-u option is ignored.
-M: run the db2look utility in simulated mode.
This option generates a script containing the SQL update statement.
These SQL update statements capture all statistics
You can run this script on another database to copy the initial one.
If the-M option is specified, the-P,-G, and-s options are ignored.
-C: do not generate a simulated commit statement
This option is ignored unless-M or-E is specified.
Connect and connect reset statements will not be generated
Commit is omitted. After the script is executed, it must be implemented explicitly.
-R: do not generate a simulated runstats statement.
The default value is runstats. This option is valid only when-M is specified.
-L: generate the database layout: database partition group, buffer pool, and tablespace.
-X: If this option is specified, the db2look utility generates the authorization DDL
For existing authorized privileges, excluding the object's original definer
-XD: If this option is specified, the db2look utility generates the authorization DDL
For existing authorized privileges, including the object's original definer
-F: Extracts configuration parameters and environment variables.
If this option is specified, the-wrapper and-server options are ignored.
-FD: generates the db2fopt statement for opt_buffpage, opt_sortheap, and other configuration and environment parameters.
-TD: Specify X as the statement delimiter (the default Delimiter is semicolon (;))
It should be used with the-E Option (if the trigger or SQL routine exists)
-P: in plaintext format
-S: generate a postscript File
This option will generate a postscript file for you
When this option is set, all latex and tmp ps files are removed.
Required (non-IBM) software: latex and dvips
Note: The file psfig. Tex must be in the latex input path.
-G: displays index page access pairs using graphs.
Gnuplot must be installed and <psfig. Tex> must be in your latex input path
The <FILENAME. PS> file will also be generated along with the latex File
-I: the user ID used to log on to the server where the database resides.
-W: The password used to log on to the server where the database resides.
-Noview: do not generate the create view DDL statement.
-Wrapper: Generate DDL for the Union object that applies to this wrapper
The generated object may contain the following items:
Package, server, user ing, nickname, type ing,
Function templates, function ing, and index specifications
-Server: Generate DDL statements for the associated objects on this server.
The generated object may contain the following items:
Package, server, user ing, nickname, type ing,
Function templates, function ing, and index specifications
-Nofed: do not generate federated DDL
If this option is specified, the-wrapper and-server options are ignored.

Latex layout: latex filename. Tex to get filename. DVI

Example: db2look-D department-u Walid-e-o db2look. SQL

-- This generates DDL statements for all tables and associated objects created by user Walid.
-- The db2look output is sent to a file named db2look. SQL.

Example: db2look-D department-Z myscm1-e-o db2look. SQL

-- This will generate DDL statements for all tables with the schema name myscm1
-- DDL of all associated objects created by $ user is also generated.
-- The db2look output is sent to a file named db2look. SQL.

Example: db2look-D department-u Walid-m-o db2look. SQL

-- This generates an update statement to capture statistics about the table/nickname created by the user Walid.
-- The db2look output is sent to a file named db2look. SQL.

Example: db2look-D department-u Walid-e-wrapper W1-O db2look. SQL

-- This will generate DDL statements for all tables created by user Walid
-- DDL will also be generated for all Union objects created by user Walid of the package W1
-- The db2look output is sent to a file named db2look. SQL.

Example: db2look-D department-u Walid-e-server S1-O db2look. SQL

-- This will generate DDL statements for all tables created by user Walid
-- DDL for all associated objects created by user Walid of server S1 will also be generated
-- The db2look output is sent to a file named db2look. SQL.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.