what is Constraint? How many types of constraints in SQL ?
Answers were Sorted based on User's Feedback
Answer / sowndharya-bca gvg colleg
constraints are enforced on data being stored in a table
1-primary key constraint
2-foreign key constraint
3-unique key constraint
other constraints~~~~:
business rule constraints
column level constraints
table level constraints
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / agasaud
Constraints are Boundaries or Rules To Set on a Table.
Types of Constraints are :
Primary Key
Uniwue Key
Check Constraints
Default Constraints
Not Null
References
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / balamurugan
only five constraint in sql server
Types of Constraints are:
1)Not Null
2)Unique
3)Foreign Key
4)Check
5)Default.
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / nivetha sri
Constraint are the certain condition which is used to
limit the data in the table.It can used before creating the
table and after creating the table.
TYPES OF CONSTRAINTS
1] Primary key
2]Foreign key
3]Unique key
4]Check
5]Not Null
6]Default
Is This Answer Correct ? | 1 Yes | 1 No |
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 |
Answer / raghunath k
Constraints are some rules that are inforced on the data object.
there are five types of costriants in SQL, they are
1. NOT NULL CONSTRAINTS.
2. UNIQUE CONSTRAINTS.
3. PRIMARY KEY CONSTRAINTS.
4. FOREIGN KEY CONSTRAINTS.
5. CHECK CONSTRAINTS.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / shreevats
Constraints are the conditions which allows to restrict the invalid or inconsistent data in the tables.
Types of Constraints
1.Not null:Not null make any column as mandatory and it will not allows the null values.
2.Unique:It will not allows duplicate values.
3.Primary Key:A PK is used to identify a record uniquely in a table.
PK=UNIQUE+NOT NULL
4.Foreign Key or Referential Integrity constraint
:It creates the relationship between any two tables.
5.Check: It is used for enforcing business validation.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / rehan khan
constraint enforces rules at the table level and prevent the deletion of a table if there are dependencies .
constraint type:
primary key
foreign key
unique
not null
null
check
constraints can be defined at the time of table creation or after table has been created.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / tosh
constraint is a mechanism applied on a column to restrict the user not to enter null values,duplicate and invalid data.
Is This Answer Correct ? | 0 Yes | 0 No |
What does COMMIT command do?
can you tell me some sites name for sql server 2000 commands with example??? plz reply soon.
What is the difference between rank and dense_rank?
is there more the two primary key in a single table?
26 Answers Eforce, Systematix,
What is wide table?
Why would you call update statistics?
What is difference beteen Migration and Upgrdation?
what are three different authentications to connect linked servers?
What is the use of attributehierarchyvisible ? : sql server analysis services, ssas
What is temporary table in sql server? Why we use temp table?
Can you please explain the difference between function and stored procedure?
What are unicode character string data types in ms sql server?