|
|||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||
|
As we may know, Oracle provides referential integrity via constraints. The Oracle DBA can define primary key and foreign key constraints, with either the ON DELETE CASCADE or ON DELETE NO ACTION clauses, thereby enforcing business rules at the database level. However, creating indexes on constraints has been somewhat problematic because Oracle would assign a cryptic internal name to the indexes that support all unique constraints. Internally, Oracle enforces PRIMARY and UNIQUE constraints by building a unique index on the specified column. This ensures that no duplicate rows are added to the column. In Oracle9i, the index used to support primary and unique keys can be defined independently of the constraint itself by using the CREATE INDEX syntax within the USING INDEX clause of the CREATE TABLE statement: CREATE TABLE
student Once defined, the unique constraint can be dropped without dropping the index. ALTER TABLE student DROP PRIMARY KEY KEEP INDEX; ALTER TABLE student DROP CONSTRAINT student_pk; This adds additional flexibility to referential integrity and allows the Oracle9i DBA to manage indexes independently of constraints.
|
|
|||||||||||||||||||||||||||||||
|