Select chapter



Basics (2.papers)
Data Types (2.papers)
Table-designing (1.papers)
Queries-Commands (3.papers)
String functions (2.papers)
Subqueries (1.papers)
Joins (1.papers)
Constraints (1.papers)
Triggers (1.papers)
Hide

Sponsored Links


  

sql interview questions and answers

1
What is the use of constraints in SQL Server?
  1. Constraints are used for restricting data coming into tables.
  2. Constraints are used for enforcing business rules.
  3. Constraints used for validating data.
  4. All of the above.
Show Answer
Share Facebook gmail Twitter
2
What is the use of not null constraint?
  1. not null constraint is used for checking whether a value is null or not in the conditional statements.
  2. when not null constraint is applied on any column it will not allow null values into the column.
  3. All the options are correct.
Show Answer
Share Facebook gmail Twitter
3
Which of the following code applies not null constraint on the fname column of employees table?
  1. create table employees
    (
       eid int ,
       fname varchar(20) notnull
    )
  2. create table employees
    (
       eid int ,
       fname varchar(20) not null
    )
Show Answer
Share Facebook gmail Twitter
4
What is the use of default constraint?
  1. default constraint inserts default value into the column when user not supplying any value.
  2. default constraint will always insert default value into the columns irrespective of users data.
  3. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
5
Which of the following code defines bangalore as default city, when user is not passing city name into employees table?
  1. create table employees
    (
       eid int ,
       city varchar(30) default='bangalore'
    )
  2. create table employees
    (
       eid int ,
       city varchar(30) default bangalore
    )
  3. create table employees
    (
       eid int ,
       city varchar(30) default 'bangalore'
    )
  4. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
6
Which of the following code defines current date as default date into dateofjoining column?
  1. create table employees
    (
       eid int ,
       dateofjoining date default currentdate 
    )
  2. create table employees
    (
       eid int ,
       dateofjoining date default getdate()
    )
  3. create table employees
    (
       eid int ,
       dateofjoining date default getdate
    )
  4. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
7
What is the use of check constraint?
  1. check constraint in sql useful for validating range of values.
  2. check constraint used for limiting values allowed into a column.
  3. Both the options are correct.
Show Answer
Share Facebook gmail Twitter
8
Which of the following code defines check constraint for allowing only patients age between 1 to 100?
  1. create table patients
    (
        pid int ,
        name varchar(40),
       age int between  (1 and 40 )
    )
  2. create table patients
    (
        pid int ,
        name varchar(40),
       age int check between  (1 and 40 )
    )
  3. create table patients
    (
       pid int , name varchar(40) , age int check (age between 1 and 100 )
    )
  4. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
9
What is a Primary Key?
  1. A primary key is a constraint , if it is applied on any column then the column will not allow duplicate values.
  2. A primary key is a constraint which will make the table rows unique.
  3. A primary key will make all rows present in a table unique and will not allow null values.
  4. All the above.
Show Answer
Share Facebook gmail Twitter
10
What is a composite Primary Key?
  1. A primary key applied on more than one column is called as composite column.
  2. When a table contains more than one primary key then the table is said to have composite primary key.
  3. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
11
What is an unique constraint?
  1. Unique constraint will not allow duplicate values into the columns on which it is defined.
  2. Unique constraints makes table rows unique.
  3. Unique constraints will not allow redundant rows but will allow one null value.
  4. All of the above.
Show Answer
Share Facebook gmail Twitter
12
Which of the following statements is not correct about unique constraint?
  1. Unique constraint will allow one null value.
  2. Unique constraint makes a row unique.
  3. It is possible to create more than one unique constraint on a table.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
13
What is a Foreign Key Constraint ?
  1. Foreign key constraint used for restricting child columns data.
  2. Foreign key constraint used for establishing relation ship between two tables.
  3. A foreign key constraint will allow values present in referencing table columns into child table columns.
  4. All the above.
Show Answer
Share Facebook gmail Twitter
14
Which of the following syntax is correct for declaring foreign key constraint?
  1. create table t1
    (
       c1 int primary key,
       c2 varchar(40),
       --other columns
    )
    create table t2
    (
        c4 int primary key ,
        c5 int foreign key references t1(c1)
    )
  2. create table t1
    (
       c1 int primary key,
       c2 varchar(40),
       --other columns
    )
    create table t2
    (
        c4 int primary key ,
        c5 int ,
        constraint fk_somename foreign key (c5) references t1(c1)
    )
  3. Both the options are correct.
  4. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
16
What is the difference between unique and primary key constraints?
  1. Only one primary key constraint is allowed per table, more than one unique constraints is allowed per table.
  2. Unique constraint will allow one null value and primary key constraint will not allow null values.
  3. Both the options are correct.
  4. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
17
What is meant by normalization?
  1. Normalization is the process of splitting a table into multiple tables to avoid data duplication or redundancy.
  2. Normalization is a technique used for removing null values present in a table.
  3. Normalization technique used for removing duplicate rows present in a table.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
18
Which of the following code is a valid Check Constraint ?
  1. create table Employees
    (
       eid int,  
       name varchar(40),
       age int,
       exp int check (exp<age)
    )
  2. create table Employees
    (
       eid int,  
       name varchar(40),
       age int,
       exp int ,
      constraint chk_age_exp check (age>exp)
    )
  3. create table Employees
    (
       eid int,  
       name varchar(40),
       age int,
       exp int ,
      constraint check (age>exp)
    )
Show Answer
Share Facebook gmail Twitter
Read more papers :