background image
<< Use a table-level constraint | FOR UPDATE clause >>

Statement dependency system

<< Use a table-level constraint | FOR UPDATE clause >>
Derby Reference Manual
80
REFERENCES Flights (FLIGHT_ID, SEGMENT_NUMBER)
);
-- add a unique constraint to a column
ALTER TABLE SAMP.PROJECT
ADD CONSTRAINT P_UC UNIQUE (PROJNAME);
-- create a table whose city_id column references the
-- primary key in the Cities table
-- using a column-level foreign key constraint
CREATE TABLE CONDOS
(
CONDO_ID INT NOT NULL CONSTRAINT hotels_PK PRIMARY KEY,
CONDO_NAME VARCHAR(40) NOT NULL,
CITY_ID INT CONSTRAINT city_foreign_key
REFERENCES Cities ON DELETE CASCADE ON UPDATE RESTRICT
);
Statement dependency system
INSERT and UPDATE statements depend on all constraints on the target table.
DELETEs depend on unique, primary key, and foreign key constraints. These statements
are invalidated if a constraint is added to or dropped from the target table.
Column-level-constraint
{
NOT NULL |
[ [CONSTRAINT
constraint-Name
]
{
CHECK (
searchCondition
) |
{
PRIMARY KEY |
UNIQUE |
REFERENCES clause
}
}
}
Table-level constraint
[CONSTRAINT
constraint-Name
]
{
CHECK (
searchCondition
) |
{
PRIMARY KEY (
Simple-column-Name
[ ,
Simple-column-Name
]* ) |
UNIQUE (
Simple-column-Name
[ ,
Simple-column-Name
]* ) |
FOREIGN KEY (
Simple-column-Name
[ ,
Simple-column-Name
]*
)
REFERENCES clause
}
}
References specification
REFERENCES
table-Name
[ (
Simple-column-Name
[ ,
Simple-column-Name
]* )
]
[ ON DELETE {NO ACTION | RESTRICT | CASCADE | SET NULL}]
[ ON UPDATE {NO ACTION | RESTRICT }]
|
[ ON UPDATE {NO ACTION | RESTRICT }] [ ON DELETE
{NO ACTION | RESTRICT | CASCADE | SET NULL}]
searchCondition
A searchCondition is any
Boolean expression
that meets the requirements specified in
Requirements for search condition
.