Column Line Commands
Review the following line commands
Review the following column line commands:
Standard ISPF Line Commands
The column definition section of the table screen supports standard ISPF line commands for defining and editing your table's columns. Some of the line and block commands supported are insert (I), copy (C), delete (D), repeat (R), and move (M). Special line commands, P# and F#, are provided to define referential rules.
- E (explode)Column Explode Detail lets you perform all attribute editing for a column on one screen.
- T (type)Select a data type for the column from a list of column types.
- U (undo)Removes changes you have made to a column.
- Res (reset)Reset the value of the column to its original value.
The table option offers some special line commands to aid in defining column information. These options are discussed at this time because they apply to three table options: Create, Alter, and Template.
Column Explode Detail (E)
The Column Explode Detail screen presents all the available attributes for a column on a single screen. To display the Column Explode Detail Screen, enter
Enext to each column with which you want to work. The Column Explode option does not need to be used to edit a column's attributes. The benefit of the Column Explode Detail screen is that all attributes are on the screen. If more than one column has been selected, each column is processed individually, in the order of their appearance in the table.
From this screen, two new primary commands are available:
- TYPELets you select a data type for the columns from a list of column types.
- VALUELets you specify a default value for a new column.
The most current or new data for each column is always displayed, unless specified otherwise. When current data appears, NEW appears in the Data Type field. If any column data is changed, the data associated with the column at the beginning of the session is considered OLD.
Newly inserted columns do not have old data. Therefore, OLD cannot be entered in this field for a newly inserted column.
Enter information in these fields exactly as in the Table Create, Template, or Alter screen (see Table Create). Invoke the Column Type Screen by entering an asterisk (*) or an invalid data type in the Column Type field.
When finished with the Column Explode screen, press the F3 (End) key to return to the Table Screen. Any changes made on the Explode screen are shown on the Table Screen. If changes were made on the Explode screen that should be canceled, press F3 (End) to exit the screen and enter the RES (reset) line command next to the column on the table screen. This will reset the column back to its previous definition.
If more than one column has been selected, the next column automatically appears when F3 (End) is presented. Once all selected columns have been processed, pressing F3 (End) displays the table screen.
Column Type Selection (T)
The Column Type Selection panel makes it possible to select a data type for a column by choosing the data type from a list of valid column types. If changing the column type, the current value appears. To select a Column Type for a column, enter
Tin the line command area. More than one column can be selected simultaneously. Each column will be processed individually, starting with the first selected column. The others will be processed in turn, in the order of their appearance in the table. Enter a question mark (
?) or any other invalid data type in the Column Type Field to bring up the Column Type Selection panel.
Detailed information about the previous column data types can be found in the Table Create.
If more than one column has been selected, a column type screen for the column next in the table will be displayed. If this is the last column being processed, the Table Create, Template, or Alter screen displays.
To proceed to the next step without changing the data type, press the F3 (End) key without making a data type selection.
Reset (RES) or Undo (U)
If changes are made to a column and you want to return the column to its original definition, enter the U (UNDO) or RES (RESET) line command next to the column name. This will retrieve the original definition of the column before any changes were made.
To undelete a column that has been deleted, enter the C (COMPARE) command to invoke the compare screen. Find the deleted column and enter the U or RES command on the Column Deleted line.
For inserted columns, a Column Inserted line appears. If the RES command is entered on an inserted column, it is removed.
Insert a New First Column (I)
Line commands are very powerful tools for changing the columns in a table. Columns can be inserted, deleted, repeated or moved using the ISPF-like line commands in CA products. Two common situations need more clarification.
I(INSERT) line command inserts a new line for a new column following the line on which it is entered, inserting a new column as the first column in a table requires multiple steps.
Follow these steps:
- Enter the I (INSERT) line command for any of the columns in the table.
- Specify the new column name and attributes on the newly inserted line.
- Move the new column to the first position:
- Type the M (move) line command on the line defining the new column.
- Type the B (BEFORE) line command on the line defining the first column.
- Press Enter to perform the move.
This is the only way to insert a new first column in a table. If done incorrectly, data could be lost.
Specifying Default Values for New Columns (V)
The Column Default Value screen allows specification of a default value for a new column.
Repeating a Column (R)
R(REPEAT) line commands inserts a new column after the original column, with this new column initially showing the same column name and attributes as the original column. The data remains with the original column. Because DB2 will not allow two columns with the same name, the name of one of them must be changed.
If the name of the second (new) column is changed, the data remains with the original column, and the new column contains null values until populated.
If the name of the first (original) column is changed, so that the second (new) column retains the name of the original column, it is treated as a rename of the original column. The data remains with the first (original), but now renamed, column, and the second (new) column contains null values until populated.
The R (REPEAT) line command can be avoided. Use the I (INSERT) line command, where there is no confusion over which is the new line.
After altering a table, always issue the COMPARE command to verify the alterations.