Consider the creation of the following table: Customer(CustId, AccountNo, CustName) with combination of columns Custid and AccountNo should be UNIQUE. Which one of the following options is CORRECT?Put UNIQUE constraint on both the columns separatelyThis type of constraint is not possiblePut PRIMARY KEY constraint on both the columns separatelyPut a table level UNIQUE constraint involving both the columns
Question
Consider the creation of the following table: Customer(CustId, AccountNo, CustName) with combination of columns Custid and AccountNo should be UNIQUE. Which one of the following options is CORRECT?Put UNIQUE constraint on both the columns separatelyThis type of constraint is not possiblePut PRIMARY KEY constraint on both the columns separatelyPut a table level UNIQUE constraint involving both the columns
Solution
The correct option is to "Put a table level UNIQUE constraint involving both the columns".
Here's why:
-
Putting UNIQUE constraint on both the columns separately: This will ensure that each column individually has unique values, but it doesn't guarantee that the combination of CustId and AccountNo will be unique.
-
This type of constraint is not possible: This is incorrect. SQL does allow for multi-column unique constraints.
-
Put PRIMARY KEY constraint on both the columns separately: This is similar to the first option. It will ensure that each column individually has unique values, but it doesn't guarantee that the combination of CustId and AccountNo will be unique. Also, a table can have only one primary key.
-
Put a table level UNIQUE constraint involving both the columns: This is the correct option. It ensures that the combination of CustId and AccountNo is unique across the table.
Similar Questions
Which of the following is NOT a type of SQL constraint? UNIQUEPRIMARY KEYALTERNATE KEYFOREIGN KEY
Which of the following is not a type of SQL constraint?Select one:a. UNIQUEb. DUPLICATEc. CHECKd. FOREIGN KEY
ct the correct answerWhat SQL statement is used to add a unique constraint to a column?OptionsUNIQUECHECKPRIMARY KEYCONSTRAINT
Which SQL constraint ensures that all values in a column are unique?OptionsDEFAULTUNIQUEPRIMARY KEYCHECK
Which constraint must a primary key adhere to
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.