ALLBASE/SQL Reference Manual (36216-90216)

66 Chapter2
Using ALLBASE/SQL
Defining How Data is Stored and Retrieved
Character string data types:
CHAR(
n
)
VARCHAR(
n
)
Date/time data types:
DATE
TIME
DATETIME
INTERVAL
Binary string data types:
BINARY(
n
)
VARBINARY(
n
)
LONG BINARY(
n
)
LONG VARBINARY(
n
)
When you define a column to be of a certain data type, ALLBASE/SQL ensures that each
value stored in the column is in the range for the data type. Some data types (CHAR(
n
),
VARCHAR(
n
), BINARY(
n
), VARBINARY(
n
), LONG BINARY(
n
) and LONG VARBINARY(
n
))
require a column length. CHAR(
n
) has a default length of 1; VARCHAR(
n
) does not. Other
data types allow the specification of a precision (DECIMAL, FLOAT) and a scale (DECIMAL).
Data types also affect the operations you can perform on data. Chapter 7 , “Data Types,
defines the attributes of each data type as well as how the type affects various operations.
Specifying Column Options
You can also specify a NOT NULL, DEFAULT, native language, or constraints option for each
column. The native language and constraint options are discussed in separate sections
below.
When you define a column as NOT NULL, ALLBASE/SQL ensures that it contains no null
values. NULL is a special data type that indicates the absence of a value.
The DEFAULT option allows you to specify a default value for a column. If the DEFAULT
option is defined for a column and a value is not specified when an INSERT statement is
executed, ALLBASE/SQL inserts the default value. Default values are of the following
types:
Constant
NULL
Current date and/or time
The following example specifies column options:
CREATE TABLE PurchDB.Parts
(Column 1 char(20),
Column 2 DEFAULT NULL)