The CREATE UNIQUE INDEX command establishes a unique index on a table, prohibiting duplicate values.
Indexes, which are unseen by users, expedite data retrieval from the database, enhancing the speed of searches and queries.
This SQL statement generates an index called “uidx_pid” on the “PersonID” column within the “Persons” table.
CREATE UNIQUE INDEX uidx_pid ON Persons (PersonID); |
Please ensure to verify the syntax for creating indexes in your specific database, as it may vary across different database management systems.
Note: Updating a table with indexes is more time-consuming than updating a table without them, as indexes also require updates. Therefore, only create indexes on columns that will undergo frequent searches. |