EasyManua.ls Logo

Sybase Adaptive Server Anywhere - Page 412

Sybase Adaptive Server Anywhere
1182 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
ALTER TABLE statement
394
Syntax 1 The ALTER TABLE statement changes table attributes (column
definitions, constraints) in a table that was previously created. Note that the
syntax allows a list of alter clauses; however, only one table-constraint or
column-constraint can be added, modified or deleted in one ALTER TABLE
statement.
You cannot use ALTER TABLE on a local temporary table.
ALTER TABLE is prevented whenever the statement affects a table that is
currently being used by another connection. ALTER TABLE can be time-
consuming, and the server will not process requests referencing the table
while the statement is being processed.
Before version 5.0, all table and column constraints were held in a single
table constraint. Consequently, for these databases individual constraints on
columns cannot be deleted using the MODIFY column-name CHECK NULL
clause or replaced using the MODIFY column-name CHECK (condition )
clause. To use these statements, the entire table constraint should be deleted
and the constraints added back using the MODIFY column-name CHECK
(condition ) clause. At this point you can use MODIFY CHECK.
Syntax 2 When a table has REPLICATE ON, all changes to the table are
sent to Replication Server for replication. The replication definitions in
Replication Server are used to decide which table changes are sent to other
sites. The remainder of this section describes syntax 1.
ADD column-definition Add a new column to the table. To specify
NOT NULL, the table must be empty.
If the column has a default value, all rows of the new column are populated
with that default value.
NULL values
Adaptive Server Anywhere optimizes the creation of columns that are
allowed to contain NULL. The first column allowed to contain NULL
allocates room for eight such columns, and initializes all eight to be
NULL. (This requires no extra storage.) Thus, the next seven columns
added require no changes to the rows of the table.
Adding a ninth column then allocates room for another eight such
columns and modifies each row of the table to allocate the extra space.
Consequently, seven out of eight column additions run quickly.
ADD table-constraint Add a constraint to the table. See "CREATE
TABLE statement" on page 466 for a full explanation of table constraints.
Description
Parameters

Table of Contents

Related product manuals