An ALTER TABLE statement, issued with an ADD COLUMN clause, is used to add a column to an existing relational table. A table can contain up to 100 columns.
Note: You can use host variables for tablename and colname.
ADDRESS SQL "ALTER TABLE keywords" {tablename}
ADD COLUMN
{colname}
{datatype}
[DEFAULT string|NULL]
[UPPER CASE]
[NOT NULL]
[SYSTEM(ALL|EXT|sysnames)]
[SYSWAIT(seconds)]
[OUTPUT|NOOUTPUT]
[SYSPLEX]
OPSQL ALTER TABLE {tablename}
ADD COLUMN
{colname}
{datatype}
[DEFAULT 'string'|NULL]
[UPPER CASE]
[NOT NULL]
Defines the 1- to 18-character name of the relational table to which you are adding a column.
Defines the 1- to 18-character name of the column that you are adding.
Defines the type of data the column will store.
Data types include:
Note: We recommend using data type CHAR for most purposes, or VARCHAR if the length of the stored data differs from row to row and the full potential length of the column is seldom used. CHAR and VARCHAR are processed more efficiently than other data types.
Notes:
WHERE UPDATE = DATE '1994-04-27'
(Optional) Indicates the string is a default value to be set for this column if an INSERT statement does not provide a data value. The default string can be either a character string or a numeric string. If you are using the OPSQL command processor to invoke the ALTER TABLE statement, you must enclose the value of string in single quotes.
(Optional) Indicates that the column can contain no data. This is the default.
(Optional) The UPPER CASE keyword in a column definition specifies that the column can contain only uppercase characters. It also instructs SQL to convert any lowercase value inserted into that column to uppercase.
(Optional) Indicates that the new column cannot contain a null data value.
(Optional) Performs cross-system SQL operations. Specify one of the following values:
Routes the SQL command to all active MSF-defined systems, including the local system.
Routes the SQL command to all remote, active MSF-defined systems.
Routes the SQL command to the specified systems. You may specify from one to eight system names as the value of sysnames.
For more information, see the chapter “Using the Relational Data Framework” in the User Guide.
(Optional) Defines the number of seconds the SQL processor waits for output from a remote system. You may specify a value between 1 and 300 seconds.
Do not specify a value for SYSWAIT if you specify the SYSTEM(ALL), SYSTEM(EXT), or NOOUTPUT keywords.
(Optional) Indicates whether the command returns output to the external data queue. Specify OUTPUT to have output returned; otherwise, specify NOOUTPUT.
NOOUTPUT is implied when:
(Optional) Reduces the scope of the SYSTEM(ALL|EXT) operand to MSF connected systems that belong to the same z/OS sysplex as the command issuer. The keyword has no effect on a list of explicit system names.
Example: Add a Table Column
Add an eight-character column called OPERNAME
ADDRESS SQL "ALTER TABLE SYSTEMS ADD COLUMN OPERNAME CHAR(8) NOT NULL"
| Copyright © 2012 CA. All rights reserved. | Tell Technical Publications how we can improve this information |