Consider this unique constraint:
ALTER TABLE Posts ADD CONSTRAINT UQ_Posts_Name UNIQUE (Name);
Does it automatically create index on Name
column?
When you create a PRIMARY KEY constraint, a unique clustered index on the column or columns is automatically created if a clustered index on the table does not already exist and you do not specify a unique nonclustered index. The primary key column cannot allow NULL values.
Conclusion. Generally there is no functional difference between a unique index and a unique constraint.
A Unique index will be created automatically when you define a PRIMARY KEY or UNIQUE KEY constraints on the specified columns.
To answer to question in bold: Yes, making a field unique does index it like s primary key.
yes it does. See this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With