Chapter 6. Reverse engineering and Generate SQL 151
6.2.1 Generating SQL to PC and data source files on the iSeries server
You can generate SQL statements to a PC file and to a source member on the iSeries server.
The following steps explain how to generate the SQL statements of a group of objects to a PC
1. Expand the system that you want to use.
2. Click Databases and select the database that you want to work with.
3. Right-click the schema, which is SCHEMA01 in this example, and select Generate SQL
as shown in Figure 6-9.
Figure 6-9 Generating the SQL schema in iSeries Navigator
152 DB2 Universal Database for iSeries Administration: The Graphical Way on V5R3
4. In the Generate SQL window (Figure 6-10), complete these tasks:
a. On the Output tab, select the Write to file option.
b. For File type, select PC file to save the generated SQL in this format.
c. For Location, click Browse. Then select your directory from the pull-down list to save
Figure 6-10 Selecting Generate SQL to PC
d. In the Select window (Figure 6-11), for File name, type the name. In the Files of type
field, leave the default SQL files (.sql).
e. Click the Select button to return to the Generate SQL window.
Figure 6-11 Saving the SQL script to a PC file
Chapter 6. Reverse engineering and Generate SQL 153
f. In the Generate SQL window, click the Generate button to start generating the SQL
DDL statements for all the objects in the schema.
g. A status window opens that shows the progress of the generate SQL process as a
percentage (Figure 6-12).
Figure 6-12 Generating SQL window
154 DB2 Universal Database for iSeries Administration: The Graphical Way on V5R3
5. In the iSeries Navigator window (Figure 6-13), in the Database tasks pad, click the Run
SQL Script icon.
Figure 6-13 Selecting Run an SQL Script from the task pad
6. In the Run SQL Scripts window, click File →Open.
7. In the Open window (Figure 6-14), complete these tasks:
a. Click Look in and select the directory where you saved your file.
b. Select the file, GENSQL042 in our example, and click Open.
Figure 6-14 Restoring an SQL script file from a PC
Important: The task pad is a new function that has been added since V5R1. It is
located in the lower part of the iSeries Navigator window. If you click the various higher
level options, such as Security, Users and Groups, Database, etc., this task pad
changes accordingly. One of the database tasks of the task pad is Run SQL Script.