Previous Topic: Expressions Used in SQL Statements

Next Topic: CLOSE Statement—End Cursor Operation

ALTER TABLE Statement—Add a Table Column

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.

tablename

Defines the 1- to 18-character name of the relational table to which you are adding a column.

colname

Defines the 1- to 18-character name of the column that you are adding.

datatype

Defines the type of data the column will store.

Data types include:

Notes:

DEFAULT string

(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.

NULL

(Optional) Indicates that the column can contain no data. This is the default.

UPPER CASE

(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.

NOT NULL

(Optional) Indicates that the new column cannot contain a null data value.

SYSTEM

(Optional) Performs cross-system SQL operations. Specify one of the following values:

ALL

Routes the SQL command to all active MSF-defined systems, including the local system.

EXT

Routes the SQL command to all remote, active MSF-defined systems.

sysnames

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.

SYSWAIT

(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.

OUTPUT or NOOUTPUT

(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:

SYSPLEX

(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"