---
title: "What are some common types of constraints that can be added to SQL Server tables?"  
description: "What are some common types of constraints that can be added to SQL Server tables?"  
author: "Utpal Vishwas"  
published: 2023-05-16  
updated: 2023-05-16  
canonical: https://www.mindstick.com/forum/158356/what-are-some-common-types-of-constraints-that-can-be-added-to-sql-server-tables  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 3 minutes  

---

# What are some common types of constraints that can be added to SQL Server tables?

What are some [common](https://www.mindstick.com/articles/23170/10-most-common-accounting-mistakes-of-small-business) types of [constraints](https://www.mindstick.com/forum/34816/what-is-mapping-constraints-in-database-management-system) that can be added to [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database) [Server tables](https://www.mindstick.com/forum/160899/how-do-i-write-crud-operations-to-modify-data-in-sql-server-tables)?

## Replies

### Reply by Aryan Kumar

\
There are six main types of constraints that can be added to [SQL Server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server) [tables](https://www.mindstick.com/articles/336597/introduction-of-html-tables-for-web-development):

- **NOT NULL:** This constraint ensures that a column cannot have a NULL value.
- **UNIQUE:** This constraint ensures that all values in a column are different.
- **PRIMARY KEY:** This constraint combines the NOT NULL and UNIQUE constraints, and it also ensures that the column cannot be changed.
- **FOREIGN KEY:** This constraint ensures that the values in a column are present in another table.
- **CHECK:** This constraint ensures that the values in a column meet a specific condition.
- **DEFAULT:** This constraint sets a default value for a column if no value is specified.

These constraints can be used to improve the accuracy and reliability of data in a SQL Server database. They can also be used to enforce business rules and to improve the performance of queries.

Here are some examples of how constraints can be used:

- **NOT NULL:** This constraint can be used to ensure that a column always has a value. This can be useful for columns that are required for a query to work, or for columns that are used to track changes to data.
- **UNIQUE:** This constraint can be used to ensure that each row in a table is unique. This can be useful for columns that are used to identify rows, or for columns that are used to track changes to data.
- **PRIMARY KEY:** This constraint can be used to ensure that each row in a table is unique and cannot be changed. This can be useful for columns that are used to identify rows, or for columns that are used to track changes to data.
- **FOREIGN KEY:** This constraint can be used to ensure that the values in a column are present in another table. This can be useful for columns that are used to link tables together, or for columns that are used to enforce business rules.
- **CHECK:** This constraint can be used to ensure that the values in a column meet a specific condition. This can be useful for columns that are used to validate data, or for columns that are used to enforce business rules.
- **DEFAULT:** This constraint can be used to set a default value for a column if no value is specified. This can be useful for columns that are not always filled in, or for columns that are used to track changes to data.

Constraints can be added to tables when they are created, or they can be added to existing tables using the ALTER TABLE statement.


---

Original Source: https://www.mindstick.com/forum/158356/what-are-some-common-types-of-constraints-that-can-be-added-to-sql-server-tables

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
