TOP 10 SQL SERVER CONSTRAINTS RELATED INTERVIEW QUESTIONS

Hey developers, this time I come with most important SQL Server topic, that is known as SQL Server Constraints. If you are going to attend ...

Hey developers, this time I come with most important SQL Server topic, that is known as SQL Server Constraints. If you are going to attend SQL Server interview then you must face question related to SQL Server constraint. So this article for you, here are most top SQL server constraints related interview questions. Lest start...

SQL Constraints
NOT NULL - Surely field gets value for every row
DEFAULT- If u didnt give a value it default value will be given to field.
PRIMARY KEY- not null+unique
FOREIGN KEY- references a column of another table(mostly primary key)
UNIQUE- All the field values must be different, but it allow one null value.
CHECK CONSTRAINT-kinda integrity constraint (specifies a requirement that must be met by each row in database)

1). Define Constraints?
A constraint is a table column property with performs data validation. Using constraints, you can maintain data integrity by preventing invalid data from being entered.

2). What do you understand by Data integrity?
Data integrity is the consistency and accuracy of the data which is stored in a database.

3). Can you add constraints to a table that already has data?
Yes, But it also depend on data, like if a column containing null values and you adding not null constraint then first you need to replace all null with some values.

4). How many primary keys can exist on a table? 
One

5). What is a Foeign Key?
A FK in one table points to a PK in another table
It prevents any actions that would destroy links between tables with the corresponding data values
FK are used to enforce referential integrity

6). Difference between Primary key and Unique key constraints?
1) Unique constraints will allow a null value. If a field is nullable then a unique constraint will allow at most one null value.
2) SQL server allows many unique constraints per table where it allows just primary key per table.

7). Can we apply Uniquey key constraints on multiple columns?
Yes! Unique key constraints can be applied on a composit of multiple fields to ensure quiqueness of records.
Example : City + State in the StateList table

8). When you create an Unique key constraints then by default which index will be created by DB?
Nonclustered index would be created automatically when you will create a unique key constraints.

9). When you create an Primary key constraints then by default which index will be created by DB?
Clustered index would be created automatically when you will create a Primary key constraints.

10). What do you understand by Default constraints?
A default constraint enters a value in a column when one is not specified in the Insert or Update statement.

11). What are the type of data integrity?
In relational database, there are three type of integrity
1. Domain Integrity( data type, check constraints)
2. Entity Integrity (primary key, unique constraints)
3. Referential Integrity (handled by foregn key constraints)

12). If you does't want to check the referential integrity at the time you create the foreign key then which keyword you will use?
Then I will use WITH NOCHECK

Related

TECHNICAL 7918178810550876243

Post a comment

emo-but-icon

Follow Us

Recent

Comments

Donate

Side Ads

Text Widget

Connect Us

Sql Server 2017 Interview Questions
Sql Server Basic Interview Query Set-1
Sql Server Basic Interview Query Set-2
Sql Server Date-Time Interview Query SET-3
Sql Server Salary Interview Query SET-4
Sql Server Group By Interview Query SET-5
Sql Server Join Interview Query SET-6
Sql Server Tricky Join Interview Query SET-7
Sql Server DDL Interview Query SET-8
Small but very Tricky Sql Server Query SET-9
Very Much Tricky Query (not 4 fresher)SET-10
Sql Server Complex Interview Query SET-11
Sql Server Datatype Interview Questions
Sql Server View Interview Questions
Sql Server Index Interview Questions
TCS Tricky Sql Interview Queries
HCL Sql Interview Queries
Sql Server SP Interview Questions
Sql Server Trigger Interview Questions
Sql Server Temp Table Interview Questions
Sql Server 2016 Interview Questions
Sql Server Performance Tuning Interview Q.
Sql Server Constraints Interview Questions
Sql Server Storage/Size Interview Questions
Sql Server Very Basic Interview Questions
Sql Server Quiz for Fresher
Sql Server Icon Quiz for All
Sql Server 300+ Theoretical Interview Questions
Sql Server Complete Set

ASP.NET AND JQUERY INTERVIEW QUESTION
ASP.NET: Web Config Interview Question
ASP.NET: View State Interview Question
ASP.NET: Session Interview Question
ASP.NET: Session Interview Question 
ASP.NET: Security Interview Question
ASP.NET: Catching Interview Question
C# OOPS Interview Question
MORE Interview Question
JQUERY: Interview Question Set-1
JQUERY: Interview Question Set-2
JAVA-SCRIPT: Interview Question Set-1
JAVA-SCRIPT: Interview Question Set-2
ASP.NET MVC: Interview Question Set-1

POPULAR POSTS
10 MOST DIFFICULT INTERVIEW QUESTIONS
5 BEST INTERVIEW TIPS
YOUR 10 MISTAKE DURING INTERVIEW
2016 TOP 20 GROUP DISCUSSION TOPICS
HOW SQL PERFORMANCE AFFECTED BY DATATYPE
item