SQL Quiz
SQL Quiz
1. SQL Introduction
a. Application Programmer
b. Designer
c. Database Administrator
d. End User
a. Table
b. Column
c. Row
d. Tuple
Q5. In a relational database a referential integrity constraint can be specified with the help of
a. Primary key
b. Foreign Key
c. Secondary Key
d. None of the above
2. Normalization
a. Insert
b. Drop
c. Delete
d. Update
a. 1NF
b. 2NF
c. 3NF
d. All of the mentioned
a. Closure Dependency
b. Transitive Dependency
c. Normal Dependency
d. Functional Dependency
A. normalization of data
B. denomination of data
C. isolation of data
D. de-normalization of data
3. DDL – CREATE Table
Q 1. Which among the following is the correct syntax for creating table?
a. NOT NULL
b. CHECK
c. NULL
d. UNIQUE
a. UNIQUE
b. Primary key
c. Foreign key
d. None of the mentioned
a. MODIFY
b. RENAME TO
c. ALTER
d. None of the above
Q 1. When inserting data in a table do you always have to specify a list of all column names
you are inserting values for?
a. Yes
b. No
c. Not Sure
a. Push
b. Add
c. Insert
d. Enter
Q 4. Which of the following is used to make changes permanent in the data base.
a. Savepoint
b. Rollback
c. Commit
d. Save
Q 1. With SQL, how do you select all the records from a table named “Persons” where
the value of the column “FirstName” ends with an “a” ?
a. Single row
b. Double row
c. No row
d. None of the mentioned
a. ORDER BY
b. SORT BY
c. ALTER BY
d. UPDATE
Q5 Which of the following query is correct for using comparison operators in SQL?
A) SELECT sname, coursename FROM studentinfo WHERE age>50 and <80;
B) SELECT sname, coursename FROM studentinfo WHERE age>50 and age <80;
C) SELECT sname, coursename FROM studentinfo WHERE age>50 and WHERE age<80;
D) None of the above
7. SQL Functions
a. ROUND
b. POWER
c. ABS
d. CEILING
Q 3. Which function will return a number rounded to a certain number of decimal places?
a. ATN2
b. RADIANS
c. ROUND
d. RND
a. TRUE
b. FALSE
Q5 Find the names of those cities with temperature and conditon whose condition is either sunny or
cloudy but temperature must be greater than 70
A. SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' AND
condition = 'cloudy' OR temperature > 70;
B. SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' OR condition =
'cloudy' OR temperature > 70;
C. SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' OR condition =
'cloudy' AND temperature > 70;
D. SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' AND condition =
'cloudy' AND temperature > 70;
8. GROUP BY
Q 1. Observe the given SQL query and choose the correct option.
SELECT branch_name, COUNT (DISTINCT customer_name)
FROM depositor, account
WHERE depositor.account_number = account.account_number
GROUP BY branch_id
Q 2. State true or false: SQL does not permit distinct with count(*)
a. True
b. False
Q 3. The _____ aggregation operation adds up all the values of the attribute
a. Add
b. Avg
c. Max
d. Sum
a. Repetitive values
b. Null values
c. Characters
d. Integers
Q5 What is the significance of the statement “HAVING COUNT (emp_id)>2” in the given query?
SELECT d.name, COUNT (emp_id) emp_no
FROM department d INNER JOIN Employee e
ON d.dept_id=e.emp_id
GROUP BY d.name
HAVING COUNT (emp_id)>2
Q 1. The join operations that do not retain mismatched tuples are called as _________
operations.
a. OUTER JOIN
b. NATURAL JOIN
c. FULL OUTER JOIN
d. INNER JOIN
Q 2. What is the difference between a inner join and an outer join operation?
a. There is no difference
b. Inner join preserves a few tuples that are otherwise lost in the outer join
c. Outer join preserves a few tuples that are otherwise lost in the Inner join
d. An outer join can be used only on outer queries whereas a join operation can be used in
Subqueries
a. Equijions
b. Innerjoins
c. Cartesian
d. Selfjoins
Q 4. What type of join is needed when you wish to include rows that do not have matching
values?
a. Equi-join
b. Natural join
c. Outer join
d. All of the Mentioned
Q 1. What is a subquery?
Q 2. The ________ comparison checker is used to check “each and every” condition
a. All
b. And
c. Every
d. Each
a. True
b. False