SQL Server: Constraints and its types.

SQL Server constraints allow you to enforce rules in your database. These rules may affect business logic, database integrity and/or table structures. Each one plays an important role in your database architecture.
There are six types of constraints supported by Microsoft SQL Server:

1.    CHECK CONSTRAINTS: Check constraint defines a condition for one or more columns in a table on INSERT and UPDATE operations.

2.    DEFAULT CONSTRAINTS: It allow you to specify a value that the database will use to populate fields that are left blank in the input source. They're a replacement for the use of NULL values that provide a great way to predefine common data elements.

3.    PRIMARY KEY CONSTRAINTS: They specify fields that uniquely identify each record in the table. It can either be a normal attribute that is guaranteed to be unique. Primary keys may consist of a single attribute or multiple attributes in combination.

4.    FOREIGN KEY CONSTRAINTS: They are the fields in a relational database table that match the primary key column of another table. Foreign keys can be used to cross-reference tables.

5.    UNIQUE CONSTRAINTS: It allows SQL Server administrators to specify that a column may not contain duplicate values. When you create a new UNIQUE constraint, SQL Server checks the column in question to determine whether it contains any duplicate values.

6.    NOT NULL CONSTRAINTS: They allow you to specify that a column may not contain NULL values. When you create a new NOT NULL constraint on a database column, SQL Server checks the column's current contents for any NULL values.

 

 
 

Ebook Download
View all
SQL Jobs
Read by 0 people
Download Now!
Learn
View all
F11Research & Development, LLC