Export all DDL scripts of the database in DB2

Source: Internet
Author: User

Export all DDL scripts of the database in DB2

Run the db2look command to obtain the DDL script of the database object.
DB2's db2look command is interpreted as follows:
Db2look 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 required for database replication.
File
This option will generate include DDL
Statement script
You can run this script on another database to recreate the database object.
This option can be used with-m
Option used together
-U: create a program id: If-u
And-a are not specified, the $ user
If-A is specified
-U is ignored.
Option
-Z: Mode name: If-Z is specified at the same time
And-a,-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-TW is specified
-T option is ignored.
-V: Only DDL is generated for the view. If-T is specified
This option is ignored.
-H: More Detailed Help messages
-O: redirects the output to the specified file name.
If-O is not specified
To stdout
-A: generate statistics for all created programs
If this option is specified,-u is ignored.
Option
-M: Run db2look in simulated mode.
Utilities
This option will generate an SQL update
Statement script
These SQL updates
Statement capture all statistics
You can run this script on another database to copy the initial one.
If-M is specified
-P,-G
And-s options
-C: do not generate a simulated commit.
Statement
Unless-M is specified
Or-E. Otherwise, this option is ignored.
Connect will not be generated
And connect Reset
Statement
Commit is omitted. After the script is executed, it must be implemented explicitly.
-R: do not generate simulated runstats
Statement
The default value is runstats. Only when-M is specified
This option is valid
-L: generate the database layout: database partition group, buffer pool, and tablespace.
-X: If this option is specified, db2look
The utility will generate the authorization DDL
For existing authorized privileges, excluding the object's original definer
-XD: If this option is specified, db2look
The utility will generate 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,-wrapper is ignored.
And-Server
Option
-FD: opt_buffpage
And opt_sortheap
And other configuration and environment parameters to generate db2fopt
Statement.
-TD: Convert x
Specify as statement delimiters (the default delimiters are semicolons (;))
And-e
Option (if the trigger or SQL
If the routine exists)
-P: in plaintext format
-S: Generate postscript
File
This option will generate postscript for you
File
When this option is set, all Latex
And tmp ps files
Required (non-IBM) software: Latex
And dvips
Note: The file psfig. Tex
Must be in 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
Also with latex
File generation together <FILENAME. PS>
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 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,-wrapper is ignored.
And-Server
Option

Latex layout: latex filename. Tex
To obtain filename. DVI

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

-- This will generate the user Walid
DDL of all created tables and associated objects
Statement
-- Db2look output is sent to the table named db2look. SQL
In

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

-- This will be the mode name myscm1
All tables in
Statement
-- $ User will also be generated
DDL of all associated objects created.
-- Db2look output is sent to the table named db2look. SQL
In

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

-- This will generate an update
Statement to capture the user's Walid
Statistics of created tables/nicknames
-- Db2look output is sent to the table named db2look. SQL
In

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

-- This will generate the user Walid
DDL statements for all created tables
-- It will also generate a package for W1.
User Walid
-- Db2look output is sent to the table named db2look. SQL
In

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

-- This will generate the user Walid
DDL of all created tables
Statement
-- It will also generate an application for server S1
User Walid
-- Db2look output is sent to the table named db2look. SQL
In

 

Reprinted Article address: http://blog.csdn.net/zero_plus/article/details/6169520

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.