This set of SQL Server Multiple Choice Questions & Answers (MCQs) focuses on “Constraints”.
1. Which of the following is not a class of constraint in SQL Server?
a) NOT NULL
b) CHECK
c) NULL
d) UNIQUE
View Answer
Explanation: NOT NULL specifies that the column does not accept NULL values. For more information.
2. Point out the correct statement.
a) CHECK constraints enforce domain integrity
b) UNIQUE constraints enforce the uniqueness of the values in a set of columns
c) In a UNIQUE constraint, no two rows in the table can have the same value for the columns
d) All of the mentioned
View Answer
Explanation: Constraints let you define the way the Database Engine automatically enforces the integrity of a database.
3. Which of the following constraint does not enforce uniqueness?
a) UNIQUE
b) Primary key
c) Foreign key
d) None of the mentioned
View Answer
Explanation: FOREIGN KEY constraints identify and enforce the relationships between tables.
4. Constraints can be applied on ___________
a) Column
b) Table
c) Field
d) All of the mentioned
View Answer
Explanation: Constraints can be column constraints or table constraints.
5. Point out the wrong statement.
a) Table constraints must be used when more than one column must be included in a constraint
b) A column constraint is specified as part of a column definition and applies only to that column
c) A table constraint is declared independently from a column definition and can apply to more than one column in a table
d) Primary keys allow for NULL as one of the unique values
View Answer
Explanation: Primary keys also enforce uniqueness, but primary keys do not allow for NULL as one of the unique values.
6. Purpose of foreign key constraint in SQL Server is __________
a) FOREIGN KEY constraints identify and enforce the relationships between tables
b) A foreign key in one table points to a candidate key in another table
c) You cannot insert a row with a foreign key value, except NULL, if there is no candidate key with that value
d) None of the mentioned
View Answer
Explanation: Foreign key is to enforce referential integrity.
7. Which of the following is not a foreign key constraint?
a) NO ACTION
b) CASCADE
c) SET NULL
d) All of the mentioned
View Answer
Explanation: Foreign key Constraints are the built-in mechanism for enforcing data integrity.
8. Which of the following foreign key constraint specifies that the deletion fails with an error?
a) NO ACTION
b) CASCADE
c) SET NULL
d) All of the mentioned
View Answer
Explanation: The ON UPDATE clause defines the actions that are taken if you try to update a candidate key value to which existing foreign keys point.
9. How many types of constraints are present in SQL Server?
a) 4
b) 5
c) 6
d) 7
View Answer
Explanation: Constraints are Primary key, Foreign Key, Unique Key, Not Null, Check, Default.
10. Which of the constraint can be enforced one per table?
a) Primary key constraint
b) Not Null constraint
c) Foreign Key constraint
d) Check constraint
View Answer
Explanation: Each table is having only one primary key constraint and it contains only unique values.
Sanfoundry Global Education & Learning Series – SQL Server.
To practice all areas of SQL Server, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Practice Programming MCQs
- Apply for Programming Internship
- Check Information Technology Books
- Check SQL Server Books