Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is Constraint? How many types of constraints in SQL ?

Answer Posted / kannan

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. The six types
of constraints supported by Microsoft SQL Server include:

UNIQUE constraints allow 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. If the table contains preexisting
duplicates, the constraint creation command fails.
Similarly, once you have a UNIQUE constraint on a column,
attempts to add or modify data that would cause duplicates
to exist also fail.
CHECK constraints allow you to limit the types of data
that users may insert in a database. They go beyond data
types and allow you to define the specific values that may
be included in a column.
DEFAULT constraints 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.
NOT NULL constraints 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. If the column
currently contains NULL values, the constraint creation
fails. Otherwise, SQL Server adds the NOT NULL constraint
and any future INSERT or UPDATE commands that would cause
the existence of a NULL value fail.
PRIMARY KEY constraints specify fields that uniquely
identify each record in the table. It can either be a normal
attribute that is guaranteed to be unique (such as Social
Security Number in a table with no more than one record per
person) or it can be generated by the DBMS (such as a
globally unique identifier, or GUID, in Microsoft SQL
Server). Primary keys may consist of a single attribute or
multiple attributes in combination.
FOREIGN KEY constraints are fields in a relational
database table that match the primary key column of another
table. Foreign keys can be used to cross-reference tables.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What structure can you implement for the database to speed up table reads?

1163


what is a join? : Sql server database administration

1144


Why does sql studio use a single registered database repository? : sql server management studio

957


Can sql servers link to other servers like oracle?

799


How to replace given values with null using nullif()?

932


How to connect Azure federated root database and apply federation in entity framework?

107


How to rebuild master databse?

1038


Difference between report and query parameter. Why do we need different type of parameter?

910


What are the disadvantages of primary key and foreign key in SQL?

1060


What is service broker?

967


How to return the top 5 rows from a select query in ms sql server?

1082


Does partitioning help performance?

896


What is truncate table?

902


Does sql server 2000 full-text search support clustering?

822


Do you know what are pages and extents? : SQL Server Architecture

948