patternModerate
What is this upside-down silver key icon
Viewed 0 times
thisiconwhatsilverdownkeyupside
Problem
I inherited a SQL Server 2005 3rd party server and database to look into to be able to generate reports and dashboards on.
On one table, I found a new icon: a blue-silver upside-down key, alongside my other primary and foreign keys.
When I right-click it, the context menu gives me the option to "Script Constraint as", but when I try to "Modify" it, it opens the column design form (like primary keys), and yet, it appears in the "Indexes" section, not constraints.
Someone knows what it is called and what it is used for?
On one table, I found a new icon: a blue-silver upside-down key, alongside my other primary and foreign keys.
When I right-click it, the context menu gives me the option to "Script Constraint as", but when I try to "Modify" it, it opens the column design form (like primary keys), and yet, it appears in the "Indexes" section, not constraints.
Someone knows what it is called and what it is used for?
Solution
It's signifying a unique constraint. In SQL Server, a unique constraint is actually implemented as an index under the covers; this is why it appears under the
You should see a result here to validate that this is actually implemented as an index:
You said that you saw "Script Constraint As..." - if you followed through with that it would have provided you a script something like:
But don't run it because this syntax does not use a name and it will just create a second, redundant unique constraint...
Here is a very simple repro, and proof that I get the upside-down key even with very basic syntax, on 2014:
click to enlarge
Now, you can get a different icon if you create a unique index explicitly (and the only differences you'll see in
click to enlarge
For other differences see this Stack Overflow answer.
Indexes node as well (I can't give you a good explanation of why it is not at least listed under the Constraints node, nor why they chose an upside down key instead of just a different color). You should see a result here to validate that this is actually implemented as an index:
SELECT index_id, type_desc, is_unique_constraint
FROM sys.indexes
WHERE name = N'IX_tblCustIndex';You said that you saw "Script Constraint As..." - if you followed through with that it would have provided you a script something like:
ALTER TABLE [dbo].[tblCustIndex] ADD UNIQUE NONCLUSTERED
(
[some_column] ASC
) WITH (...a bunch of default options...)But don't run it because this syntax does not use a name and it will just create a second, redundant unique constraint...
Here is a very simple repro, and proof that I get the upside-down key even with very basic syntax, on 2014:
CREATE TABLE dbo.foo(id INT UNIQUE);click to enlarge
Now, you can get a different icon if you create a unique index explicitly (and the only differences you'll see in
sys.indexes are the name and the value of is_unique_constraint):click to enlarge
For other differences see this Stack Overflow answer.
Code Snippets
SELECT index_id, type_desc, is_unique_constraint
FROM sys.indexes
WHERE name = N'IX_tblCustIndex';ALTER TABLE [dbo].[tblCustIndex] ADD UNIQUE NONCLUSTERED
(
[some_column] ASC
) WITH (...a bunch of default options...)CREATE TABLE dbo.foo(id INT UNIQUE);Context
StackExchange Database Administrators Q#93830, answer score: 12
Revisions (0)
No revisions yet.