Using Table And Column Constraints; Using Unique Constraints On Columns Or Tables - Sybase Adaptive Server IQ 12.4.2 Administration And Performance Manual

Table of Contents

Advertisement

Using table and column constraints

Using UNIQUE constraints on columns or tables

Example 1
Example 2
The CREATE TABLE statement and ALTER TABLE statement can specify
many different attributes for a table. Along with the basic table structure
(number, name and data type of columns, name and location of the table), you
can specify other features that allow control over data integrity.
Warning!
Altering tables can interfere with other users of the database.
Although the ALTER TABLE statement can be executed while other
connections are active, it is prevented if any other connection is using the table
to be altered. For large tables, ALTER TABLE can be a time-consuming
operation, and no other requests referencing the table being altered are allowed
while the statement is being processed.
This section describes how to use constraints to help ensure that the data
entered in the table is correct, and to provide information to Adaptive Server
IQ that boosts performance.
The
constraint specifies that one or more columns uniquely identify
UNIQUE
each row in the table. If you apply the
Adaptive Server IQ enforces this condition. If multiple columns are required to
uniquely identify a row, you must specify
constraint.
is essentially the same as a
UNIQUE
can specify more than one
and
, a column must not contain any
PRIMARY KEY
The following example adds the column
ensures that each value in it is unique throughout the table.
ALTER TABLE employee
ADD ss_number char(11) UNIQUE
In this example, three columns are needed to make a unique entry. Therefore,
the
constraint is unenforced.
UNIQUE
ALTER TABLE product
ADD UNIQUE (name, size, color) UNENFORCED
CHAPTER 7
constraint to a single column,
UNIQUE
UNIQUE
PRIMARY KEY
constraint in a table. With both
UNIQUE
ss_number
Ensuring Data Integrity
as an unenforced table
constraint, except that you
UNIQUE
values.
NULL
to the
table, and
employee
277

Advertisement

Table of Contents
loading

Table of Contents