SQL Server Questions and Answers – Constraints

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

Answer: c
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

Answer: d
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

Answer: c
Explanation: FOREIGN KEY constraints identify and enforce the relationships between tables.
advertisement
advertisement

4. Constraints can be applied on ___________
a) Column
b) Table
c) Field
d) All of the mentioned
View Answer

Answer: d
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

Answer: d
Explanation: Primary keys also enforce uniqueness, but primary keys do not allow for NULL as one of the unique values.
Note: Join free Sanfoundry classes at Telegram or Youtube

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

Answer: a
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

Answer: b
Explanation: Foreign key Constraints are the built-in mechanism for enforcing data integrity.
advertisement

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

Answer: a
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

Answer: c
Explanation: Constraints are Primary key, Foreign Key, Unique Key, Not Null, Check, Default.
advertisement

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

Answer: a
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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.