The ALTER TABLE statement adds a column to or removes a column from an existing database table.
LSQL ALTER TABLE tablename [[ADD COLUMN] [ADD_COLUMNcolname] [datatype [[UPPER CASE] [NOT NULL ] [DEFAULT value]]] [DROP COLUMN] [colname]]
Parameters
Adds a new column to an existing table.
1‑ to 18‑character name of the column you are adding or dropping.
Type of data the column can store:
Character data, with length being the maximum number of characters. A column of this type must be from 1 through 32000 bytes in length.
Date indicator of the form yyyy‑mm‑dd; for example, 2001‑08‑31.
Decimal data, with the maximum number of digits being 15.
Approximate numeric data, 8‑byte length.
Approximate numeric data of variable length; mantissa 2‑16 digits, exponent range e‑60 to e60.
Hexadecimal data, with length as the maximum number of hexadecimal bytes.
32‑bit integer data, with a maximum value of 2147483647.
Approximate numeric data, 4‑byte length.
16‑bit integer data with a maximum value of 32767.
Time indicator of the form hh:mm:ss; for example, 13:21:53.
Date/time indicator, the format being a combination of the DATE and TIME formats.
Note: The DATE, TIME, and TIMESTAMP data types are stored as unsigned packed decimal numbers. When inserting, updating, deleting, or searching for these values, specify the data type with the value. For example:
WHERE CLOSE_DATE = DATE '2001‑08‑31'
Value to be set for this column if an INSERT statement does not provide one. The default value can be a character string or a numeric value; however, it must be compatible with the data type of the column.
Drops a column from an existing table.
Indicates that the column cannot contain a null value.
Name of the relational table to which you are adding or from which you are dropping a column.
Converts the entries in the column to upper case characters.
Notes:
Example
To add a 2‑character column that is named RET_CODE to the APPLICATIONS table, issue this LSQL command:
LSQL ALTER TABLE APPLICATIONS ADD COLUMN RET_CODE CHAR(2) DEFAULT '0'
Copyright © 2014 CA Technologies.
All rights reserved.
|
|