db_ddl_object script

The db_ddl_object script dumps out the SQL DDL statements that were used to create any object of any type, that is, CREATE statements.

The db_ddl_object command is part of the Db2 support tools, and it is a general purpose wrapper for other db_ddl_* scripts:
  • db_ddl_grant_user
  • db_ddl_comment
  • db_ddl_table
  • db_ddl_view
  • db_ddl_sequence
  • db_ddl_synonym
  • db_ddl_function
  • db_ddl_procedure
  • db_ddl_ext_table
To run it, a database name is required following -d | -db. By default, the GRANT...TO USER and COMMENT ON statements are always produced. You can then use other options to specify the database objects to further narrow down the outputs.

Syntax


db_ddl_object  -d|-db <database_name> [-schema <schema_name>]
				[-table <table_name>]
				[-view <view_name>]
				[-seq|-sequence <sequence_name>]
				[-synonym <synonym_name>]
				[-f|function <function_name>]
				[-p|procedure <procedure_name>]

Parameters

-db database_name

Specifies a database name. This parameter is required.

-cor
Generate DDL with CREATE OR REPLACE clause for applicable statements.
-schema <schema_name>

Specifies a schema name. If specified, the SQL/DDL statements pertaining to the objects belonging only to that schema are generated.

-table <table_name>

Display the SQL DDL statement that was used to create a table, that is, CREATE TABLE ...

-view <view_name>

Display the SQL DDL statement that was used to create a view, that is, CREATE VIEW viewname AS SELECT ...

-seq|-sequence <sequence_name>

Display the SQL DDL statement that was used to create a sequence, that is, CREATE SEQUENCE ...

-synonym <synonym_name>

Display the SQL DDL statement that was used to create a synonym (alias), that is, CREATE ALIAS ...

-f|function <function_name>

Display the SQL DDL statement that was used to create a user-defined function (UDF), that is, CREATE [OR REPLACE] FUNCTION ...

-p|procedure <procedure_name>

Display the SQL DDL statement that was used to create a user-defined procedure, that is, CREATE [OR REPLACE] PROCEDURE ...

Outputs

SQL DDL statements are sent to standard output.