Preventing Duplicate Index Entries

From InterBase
Jump to: navigation, search

To define an index that eliminates duplicate entries, include the UNIQUE ­keyword in CREATE INDEX. The following statement creates a unique index, PRODTYPEX, on the PROJECT table:

EXEC SQL
CREATE UNIQUE INDEX PRODTYPEX ON PROJECT (PRODUCT, PROJ_NAME);
Important: After a unique index is defined, users cannot insert or update values in indexed columns if those values already exist there. For unique indexes defined on multiple columns, like PRODTYPEX in the previous example, the same value can be entered within individual columns, but the combination of values entered in all columns defined for the index must be unique.