SQL/MX 2.x Installation and Management Guide (G06.24+, H06.03+)

Adding, Altering, and Dropping SQL/MX Database
Objects
HP NonStop SQL/MX Installation and Management Guide523723-004
9-6
Adding Columns
Java to determine if your changes are likely to cause similarly check to fail and
force automatic recompilation. If they will, you should SQL compile these modules
after making the changes to avoid expensive automatic recompilations at run time.
SQL applications that are running while you make these changes will still undergo
automatic recompilation.
For information about explicit and automatic recompilation, see the SQL/MX
Programming Manual for C and COBOL and the SQL/MX Programming Manual for
Java. For information about using DISPLAY USE OF, see Checking Module
Dependencies With DISPLAY USE OF on page 11-20 and the SQL/MX Reference
Manual.
5. Enter the ALTER TABLE statement with the ADD COLUMN clause.
6. Determine if the new column should also be added to any existing index or view or
if program changes are required. After adding the new column, follow the steps for
integrating the new column into an existing application, described following this
procedure.
7. Revise the application source code as needed to reflect your changes to the
database. Process and compile the updated source file. For more information, see
the SQL/MX Programming Manual for C and COBOL and the SQL/MX
Programming Manual for Java.
To integrate the new column into the existing database or application programs:
If you want to create a new index using the new column, follow the steps for
Adding Indexes on page 9-8.
If you want to add the new column to an existing index, first follow the steps for
Dropping Indexes on page 9-31, then follow the steps for Adding Indexes on
page 9-8 to add the new column definition. You cannot alter an index or view to
add a column.
If you want to create a new view using the new column, follow the steps for Adding
Views on page 9-17.
If you want to add the new column to an existing view, first follow the steps for
Dropping Views on page 9-39, then follow the steps for Adding Views on
page 9-17. You cannot alter a view to add a column.
If you want to use the new column in programs, you must change existing
programs to refer to the new column. You might need to change screen sections to
display the column on the screen, and you might need to change code sections to
retrieve or update the column. After you SQL compile a program changed to use
the new table definition, the program can use the column.
If you want to add constraints that control values in the new column, execute the
ALTER TABLE ADD CONSTRAINT statement at any time after the column is
added.