SQL CREATE UNIQUE INDEX Keyword
The CREATE UNIQUE INDEX command is used to create an index on a column that does not allow duplicate values. Indexes are used to improve the speed of data retrieval without changing the visible structure of the table.
SQL CREATE UNIQUE INDEX Syntax
SQL
x
1
CREATE UNIQUE INDEX index_name
2
ON table_name (column)
SQL CREATE UNIQUE INDEX Example
This creates a unique index named uidx_patientid on the patient_id column of the Patients table. The index enforces uniqueness which means no two records can have the same patient_id.
SQL
1
1
CREATE UNIQUE INDEX uidx_patientid
2
ON Patients (patient_id)
