GENERATE DDL statement for the metadata utility
To generate DDL from the catalog, you can use Classic Data Architect. You can also use the metadata utility directly on the z/OS® system. The metadata utility can generate the same kinds of objects that Classic Data Architect can generate.
| Generated DDL | Object |
|---|---|
| DROP statements | TABLE, VIEW, INDEX, PROCEDURE |
| CREATE statements | TABLE, VIEW, INDEX, PROCEDURE |
| COMMENT ON statements | TABLE, VIEW, INDEX, PROCEDURE |
| GRANT statements | TABLE, VIEW, INDEX, PROCEDURE |
| ALTER statements | TABLE, VIEW |
| Indexes | TABLE |
One situation where you might choose to create DDL from the metadata utility is in a migration. For example, you could generate DDL for objects on a test system and import those objects onto a production system. The DDL is output to the media that you specify for subsequent processing. The generated DDL is formatted for direct input into the metadata utility for creating or modifying catalog entries.
To generate DDL, the metadata utility first connects to an appropriate Classic data server specified in a CONNECT TO SERVER statement. Once connected, the catalog is accessible for queries necessary to gather data for the GENERATE DDL statements. The generated DDL is printed to SYSPRINT or recorded in the file associated with the DDLOUT DD in the CACMETAU JCL.
Syntax
Parameters
- Like-Clause:
- LIKE
LIKE ESCAPE charNOT LIKE ESCAPE char - Object-Name:
- object-name
schema-name.object-name - With-Options:
- WITH option
Considerations for the DDL output
Example 1
Generate DDL for table names belonging to USER1 and beginning with the characters VSAM_TAB. Include indexes defined on the resultant tables. Generate DROP statements for the resultant tables and indexes. Record the generated DDL in the specified z/OS data set associated with the DDLOUT DD.
Provide the following input to SYSIN, with a DDLOUT DD specified in the CACMETAU JCL:
GENERATE DDL FOR TABLE LIKE ESCAPE '!' USER1
.VSAM!_TAB%
WITH DROP,INDEX;SYSTERM contains the following metadata utility output:
********************************* TOP OF DATA **************************************
Start End Processing
Line # Line # Status Statement Object
1 1 0 CONNECT TO SERVER CACDAS
CACM001I SQLCODE = 0, INFO: Statement execution was successful.
2 3 0 GENERATE DDL FOR LIKE
CACM001I SQLCODE = 0, INFO: The generated DDL was successfully written to DDLOUT.
N/A N/A 0 DISCONNECT FROM SERVER CACDAS
CACM001I SQLCODE = 0, INFO: Statement execution was successful.
******************************** BOTTOM OF DATA ************************************
SYSPRINT contains the following metadata utility output:
********************************* TOP OF DATA **************************************
LINE NO. STATEMENT
1 CONNECT TO SERVER CACDAS TCP/9.30.136.90/5002
;
CACM001I SQLCODE = 0, INFO: Statement execution was successful.
LINE NO. STATEMENT
2 GENERATE DDL FOR TABLE LIKE ESCAPE '!' USER1
.VSAM!_TAB%
3 WITH DROP,INDEX TO DSN:USER1.GENERATE.OUTPUT;
CACM001I SQLCODE = 0, INFO: The generated DDL was successfully written to DDLOUT
******************************** BOTTOM OF DATA ************************************
Only one table created by USER1 fulfilled the search criteria for a name beginning with the characters VSAM_TAB. The z/OS data set associated with the DDLOUT DD contains the following generated DDL:
********************************* TOP OF DATA **************************************
DROP INDEX USER1
.VSAM_TABLE_IDX1
;
DROP TABLE USER1
.VSAM_TABLE
;
CREATE TABLE USER1
.VSAM_TABLE
DBTYPE VSAM
DS USER1.VSAM.VSAMFILE
(
NAME
SOURCE DEFINITION
DATAMAP OFFSET 0 LENGTH 20
DATATYPE UC
USE AS CHAR(20),
ADDRESS1
SOURCE DEFINITION
DATAMAP OFFSET 20 LENGTH 20
DATATYPE UC
USE AS CHAR(20),
ADDRESS2
SOURCE DEFINITION
DATAMAP OFFSET 40 LENGTH 20
DATATYPE UC
USE AS CHAR(20),
CITY
SOURCE DEFINITION
DATAMAP OFFSET 60 LENGTH 12
DATATYPE UC
USE AS CHAR(12),
STATE
SOURCE DEFINITION
DATAMAP OFFSET 72 LENGTH 2
DATATYPE UC
USE AS CHAR(2),
ZIP
SOURCE DEFINITION
DATAMAP OFFSET 74 LENGTH 5
DATATYPE UC
USE AS CHAR(5),
PLUS4
SOURCE DEFINITION
DATAMAP OFFSET 79 LENGTH 4
DATATYPE UC
USE AS CHAR(4) );
CREATE INDEX USER1
.VSAM_TABLE_IDX1
ON USER1
.VSAM_TABLE
(STATE
ASC, ZIP
ASC, NAME
ASC);
******************************** BOTTOM OF DATA ************************************
Example 2
Generate DDL for table names belonging to USER1 and beginning with the characters IMS_TAB. Include indexes defined on the resultant tables. Generate DROP statements for the resultant tables and indexes. Record the generated DDL in the specified z/OS data set associated with the DDLOUT DD.
Provide the following input to SYSIN, with a DDLOUT DD specified in the CACMETAU JCL:
GENERATE DDL FOR TABLE LIKE ESCAPE '!' "USER1"."IMS!_TAB%"
WITH DROP,INDEX;SYSOUT contains the following metadata utility output:
********************************* TOP OF DATA **************************************
Start End Processing
Line # Line # Status Statement Object
1 1 0 CONNECT TO SERVER CACDAS
CACM001I SQLCODE = 0, INFO: Statement execution was successful.
2 3 0 GENERATE DDL FOR LIKE
CACM001I SQLCODE = 0, INFO: The generated DDL was successfully written to DDLOUT.
N/A N/A 0 DISCONNECT FROM SERVER CACDAS
CACM001I SQLCODE = 0, INFO: Statement execution was successful.
******************************** BOTTOM OF DATA ************************************
SYSPRINT contains the following metadata utility output:
********************************* TOP OF DATA **************************************
LINE NO. STATEMENT
1 CONNECT TO SERVER CACDAS "TCP/9.30.136.90/5002";
CACM001I SQLCODE = 0, INFO: Statement execution was successful.
LINE NO. STATEMENT
2 GENERATE DDL FOR TABLE LIKE ESCAPE '!' "USER1"."IMS!_TAB%"
3 WITH DROP,INDEX TO DSN:USER1.GENERATE.OUTPUT;
CACM001I SQLCODE = 0, INFO: The generated DDL was successfully written to DDLOUT
******************************** BOTTOM OF DATA ************************************
Only one table created by USER1 fulfilled the search criteria for a name beginning with the characters IMS_TAB. The z/OS data set associated with the DDLOUT DD contains the following generated DDL:
********************************* TOP OF DATA **************************************
DROP INDEX "USER1"."IMS_TABLE_IDX1";
DROP TABLE "USER1"."IMS_TABLE";
CREATE TABLE "USER1"."IMS_TABLE" DBTYPE IMS
DS "USER1.IMS.IMSFILE"
(
"NAME" SOURCE DEFINITION
DATAMAP OFFSET 0 LENGTH 20
DATATYPE UC
USE AS CHAR(20),
"ADDRESS1" SOURCE DEFINITION
DATAMAP OFFSET 20 LENGTH 20
DATATYPE UC
USE AS CHAR(20),
"ADDRESS2" SOURCE DEFINITION
DATAMAP OFFSET 40 LENGTH 20
DATATYPE UC
USE AS CHAR(20),
"CITY" SOURCE DEFINITION
DATAMAP OFFSET 60 LENGTH 12
DATATYPE UC
USE AS CHAR(12),
"STATE" SOURCE DEFINITION
DATAMAP OFFSET 72 LENGTH 2
DATATYPE UC
USE AS CHAR(2),
"ZIP" SOURCE DEFINITION
DATAMAP OFFSET 74 LENGTH 5
DATATYPE UC
USE AS CHAR(5),
"PLUS4" SOURCE DEFINITION
DATAMAP OFFSET 79 LENGTH 4
DATATYPE UC
USE AS CHAR(4) );
CREATE INDEX "USER1"."IMS_TABLE_IDX1" ON "USER1"."IMS_TABLE" ("STATE"
ASC, "ZIP" ASC, "NAME" ASC);
******************************** BOTTOM OF DATA ************************************
