Sunteți pe pagina 1din 10

SQL Quiz

1. SQL Introduction

Q 1. What does SQL stands for?

a. Strong Question Language


b. Structured Query Language
c. Structured Question Language
d. None of the above

Q 2. _________ is not the type of user in oracle.

a. Application Programmer
b. Designer
c. Database Administrator
d. End User

Q 3. Meaning of Attribute in a RDBMS is ______________

a. Table
b. Column
c. Row
d. Tuple

Q 4. Which of the statement is true for a table in RDBMS

a. All attribute values are atomic


b. Attributes are ordered from top to bottom
c. Tuples are ordered from right to left
d. Duplicate Rows

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

Q 1. Which of the following, is not a type of Anomaly?

a. Insert
b. Drop
c. Delete
d. Update

Q 2. A primary key is a combination of :

a. Unique and Not Null Values


b. Only Unique values
c. Only NULL values
d. Only NOT NULL values

Q 3. For a table to be in 2NF, it must be in :

a. 1NF
b. 2NF
c. 3NF
d. All of the mentioned

Q 4. Third normal form is based on the concept of _______________

a. Closure Dependency
b. Transitive Dependency
c. Normal Dependency
d. Functional Dependency

Q5. Process of analyzing relation schemas to achieve minimal redundancy and


removing the anomalies of insertion, update and delete is classified as

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. CREATE TABLE name;


b. CREATE name;
c. CREATE TAB;
d. All of the above

Q 2. Which of the following is not a class of constraint in SQL?

a. NOT NULL
b. CHECK
c. NULL
d. UNIQUE

Q 3. Which of the following constraint does not enforce uniqueness ?

a. UNIQUE
b. Primary key
c. Foreign key
d. None of the mentioned

Q 4. Which of these are not a valid data type in SQL?


a. ALOB
b. BLOB
c. CLOB
d. Date

Q5 Count function in SQL returns the number of


A) Values
B) Distinct values
C) Groups
D) Columns
4. DDL Statements

Q 1. The command to eliminate a table from a database is:

a. REMOVE FROM CUSTOMER;


b. DROP FROM CUSTOMER;
c. DELETE FROM CUSTOMER;
d. TRUNCATE FROM CUSTOMER;

Q 2. Which clause is used to rename the existing table?

a. MODIFY
b. RENAME TO
c. ALTER
d. None of the above

Q 3. Which of the following functions are performed by “ALTER” clause?

a. Change the name of the table


b. Renaming the column
c. Drop a column
d. All of the mentioned
Q4. Which command defines its columns, integrity constraint in create table:
a) Create command
b) Drop table command
c) Alter table command
d) All of the Mentioned

Q5. Which of the following is/are the DDL statements?


A) Create
B) Drop
C) Alter
D) All of the Mentioned
5. DML & TCL Statements

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

Q 2. Which of the following are TCL commands?

a. UPDATE and TRUNCATE


b. SELECT and INSERT
c. GRANT and REVOKE
d. ROLLBACK and SAVEPOINT

Q 3. In SQL, which command is used to add new rows to a table??

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

Q5 DML stands for:


a. Data description languages
b. Data design languages
c. Database dictionary languages
d. Data manipulation languages
6. Select Statement

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. SELECT * FROM Persons WHERE FirstName=’a’


b. SELECT * FROM Persons WHERE FirstName LIKE ‘a%’
c. SELECT * FROM Persons WHERE FirstName LIKE ‘%a’
d. SELECT * FROM Persons WHERE FirstName=’%a%’

Q 2. In the following query how many rows will be updated?


UPDATE person
SET lname=’s’,
Fname = ’p’,
WHERE person_id = 1;
/* person_id is a primary key */

a. Single row
b. Double row
c. No row
d. None of the mentioned

Q 3. Which clause is mandatory with clause “SELECT” in Sql?


a. FROM
b. WHERE
c. GROUP By
d. All the above

Q 4. Which Clause is used to sort the stored data in alphabetical order?

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

Q 1. Which of the following is not a mathematical function ?

a. ROUND
b. POWER
c. ABS
d. CEILING

Q 2. Which of the following is the correct syntax ?

a. SELECT LOWER(CustomerName) AS LCCustomerName FROM Customers;


b. SELECT LOWER FROM Customers;
c. SELECT CustomerName AS Lower() FROM Customers;
d. SELECT CustomerName FROM LOWER(Customers);

Q 3. Which function will return a number rounded to a certain number of decimal places?

a. ATN2
b. RADIANS
c. ROUND
d. RND

Q 4. The LTRIM() function removes leading spaces from a string.

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

a. The query is syntactically correct but gives the wrong answer


b. The query is syntactically wrong
c. The query is syntactically correct and gives the correct answer
d. The query contains one or more wrongly named clauses.

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

Q 4. What values does the count(*) function ignore?

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

a) Filter out all rows whose total emp_id > 2


b) Selecting those rows whose total emp_id>2
c) Filter out all rows whose total emp_id below 2 & Selecting those rows whose total emp_id>2
d) None of the mentioned
9. JOINS

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

Q 3. Which product is returned in a join query have no join condition?

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

Q5 Which of the following is not true about SQL joins?

A - An inner join is a join of two tables returning only matching rows.


B - A left or right outer join returns the results of the inner join as well as the unmatched rows in the
left or right table respectively.
C - A full outer join returns results of an inner join as well as the results of a left and right join.
D - None of the above.
10. SUBQUERIES

Q 1. What is a subquery?

a. A subquery is a select-from-where expression that is nested within another query.


b. A subquery is any query that is nested within another query.
c. A subquery is a relation that is externally specified which can be used to handle data in
queries.
d. A subquery is a condition that excludes all the invalid tuples from the database.

Q 2. The ________ comparison checker is used to check “each and every” condition

a. All
b. And
c. Every
d. Each

Q 3. Nested Subqueries cannot be used for comparing two different sets

a. True
b. False

Q 4. Which of the following are the types of sub-queries?


a. Ordered sub-queries
b. Grouped sub-queries
c. Having sub-queries
d. Single row sub-queries

Q5 Which of the following is not true about a subquery?


A - A subquery is a SELECT statement embedded in a clause of another SELECT statement.
B - The subquery executes before the main query.
C - The result of the main query is returned to the subquery.
D - All of the above.

S-ar putea să vă placă și