Reputation: 945
i have a table T with following columns
col1 col2 col3 col4
1 1 1 1
1 1 1 2
1 1 2 1
1 1 2 1
if i set a column col2,col3,col4 as unique. how does the unique works ? will it take uniqueness of combination of each column?
Upvotes: 0
Views: 357
Reputation: 5316
Yes, the "unique-ness" is a result of all columns involved in the constraint. See SO Question
You can easily write yourself a table and test how it handles INSERT
s
Upvotes: 1
Reputation: 35
I'm not entirely sure, but I think the unique attribute has to do with indexing the table. Whichever column you set as unique, that column should be the one you call on to find a certain row. For example in a call like
UPDATE table_name SET column_name = some_value WHERE ID = some_number
the ID column should be set to unique, though I don't know whether not doing so would actually stop you from finding a specific row.
Upvotes: 0
Reputation: 2446
See here: http://www.w3schools.com/sql/sql_unique.asp
The syntax for setting multiple columns as unique is different from that of setting one column unique. If you have multiple columns as unique it is the set that is viewed for uniqueness.
Upvotes: 1