Adaptive Server Anywhere SQL features
954
Adaptive Server Anywhere SQL features
The following features of the SQL supported by Adaptive Server Anywhere
are not found in many other SQL implementations.
Full type conversion is implemented. Any data type can be compared with or
used in any expression with any other data type.
Adaptive Server Anywhere has date, time and timestamp types that includes
a year, month and day, hour, minutes, seconds and fraction of a second. For
insertions or updates to date fields, or comparisons with date fields, a free
format date is supported.
In addition, the following operations are allowed on dates:
♦
date + integer Add the specified number of days to a date.
♦
date - integer Subtract the specified number of days from a date.
♦
date - date Compute the number of days between two dates.
♦
date + time Make a timestamp out of a date and time.
Also, many functions are provided for manipulating dates and times. See
"SQL Functions" on page 303 for a description of these.
Adaptive Server Anywhere supports both entity and referential integrity.
This has been implemented via the following two extensions to the CREATE
TABLE and ALTER TABLE commands.
PRIMARY KEY ( column-name, ... )
[NOT NULL] FOREIGN KEY [role-name]
[(column-name, ...)]
REFERENCES table-name [(column-name, ...)]
[ CHECK ON COMMIT ]
The PRIMARY KEY clause declares the primary key for the relation.
Adaptive Server Anywhere will then enforce the uniqueness of the primary
key, and ensure that no column in the primary key contains the NULL value.
The FOREIGN KEY clause defines a relationship between this table and
another table. This relationship is represented by a column (or columns) in
this table which must contain values in the primary key of another table. The
system will then ensure referential integrity for these columns - whenever
these columns are modified or a row is inserted into this table, these columns
will be checked to ensure that either one or more is NULL or the values
match the corresponding columns for some row in the primary key of the
other table. For more information, see "CREATE TABLE statement" on
page 466.
Type conversions
Dates
Integrity