0% found this document useful (0 votes)
70 views

MultipleChoiceExam SQL

The document contains a 20 question SQL exam covering topics like SQL statements, joins, views, functions, grouping and stored procedures. For each question there are 3 answer options, only one of which is correct. The questions test knowledge of SQL fundamentals like SELECT statements, modifying data, aggregation, ordering results and using features like views, stored procedures and functions.

Uploaded by

Raileigh Reyes
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views

MultipleChoiceExam SQL

The document contains a 20 question SQL exam covering topics like SQL statements, joins, views, functions, grouping and stored procedures. For each question there are 3 answer options, only one of which is correct. The questions test knowledge of SQL fundamentals like SELECT statements, modifying data, aggregation, ordering results and using features like views, stored procedures and functions.

Uploaded by

Raileigh Reyes
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Rozell Joie B.

Lopez
NAME: _________________________________

SQL EXAM
1. What does SQL stand for?
A. Structured Query Language
B. Structured Question Language
C. Strong Query Language

2. True or False: True


The format SELECT-FROM-WHERE is the fundamental framework of SQL
SELECT statements.

3. How can you change "Hansel" into "Gretel" in the "LastName" column in the
Persons table?
A. MODIFY Persons SET LastName='Gretel' WHERE LastName='Hansel'
B. UPDATE Persons SET LastName='Gretel' WHERE LastName='Hansel'
C. UPDATE Persons SET LastName='Hansel' INTO LastName='Gretel'

4. With SQL, how can you delete the records where the "FirstName" is
"Peterson" in the Persons Table?
A. DELETE FROM Persons WHERE FirstName = 'Peterson'
B. DELETE ROW FirstName='Peterson' FROM Persons
C. DELETE FirstName='Peterson' FROM Persons

5. With SQL, how can you insert a new record into the "Persons" table?
A. INSERT INTO Persons VALUES ('Katy', 'Perr')
B. INSERT VALUES ('Katy', 'Perr') INTO Persons
C. INSERT ('Katy', 'Perr') INTO Persons

6. With SQL, how do you select all the records from a table named "Persons"
where the value of the column "FirstName" starts with an "a"?
A. SELECT * FROM Persons WHERE FirstName LIKE '%a'
B. SELECT * FROM Persons WHERE FirstName='%a%'
C. SELECT * FROM Persons WHERE FirstName LIKE 'a%'

7. With SQL, how do you select all the records from a table named "Persons"
where the "LastName" is alphabetically between (and including) "Hansel" and
"Gretel"?
A. SELECT * FROM Persons WHERE LastName BETWEEN 'Hansel' AND
'Gretel'
B. SELECT LastName>'Hansel' AND LastName<'Gretel' FROM Persons
C. SELECT * FROM Persons WHERE LastName>'Hansel' AND
LastName<'Gretel'
8. With SQL, how can you return all the records from a table named "Persons"
sorted descending by "FirstName"?
A. SELECT * FROM Persons ORDER BY FirstName DESC
B. SELECT * FROM Persons SORT BY 'FirstName' DESC
C. SELECT * FROM Persons SORT 'FirstName' DESC
D. SELECT * FROM Persons ORDER FirstName DESC

9. Given two tables (employees and departments table). You want to retrieve all
employees, whether or not they have matching departments in the
departments table. Which query would you use?

A) SELECT last_name, department_name


FROM employees e LEFT OUTER
JOIN departments d ON (e.department_id = d.department_id);

B) SELECT last_name, department_name


FROM employees e RIGHT OUTER
JOIN departments d ON (e.department_id = d.department_id);

C) SELECT last_name, department_name


FROM employees e FULL OUTER
JOIN departments d ON (e.department_id = d.department_id);

10. Given the SQL statement below:

SELECT employee_id, e.department_id, department_name, salary


FROM employees e, departments d
WHERE e.department_id = d.department_id;

Which SQL statement is equivalent to the above SQL statement?

A) SELECT employee_id, department_id, department_name, salary


FROM employees
WHERE department_id IN (SELECT department_id
FROM departments);

B) SELECT employee_id, department_id, department_name, salary


FROM employees
NATURAL JOIN departments;

C) SELECT employee_id, d.department_id, department_name, salary


FROM employees e
JOIN departments d
ON e.department_id = d.department_id;
11. Which is true regarding the use of outer joins?

A) You cannot use IN operator in a condition that involves an outerjoin.


B) You use (+) on both sides of the WHERE condition to perform an
outerjoin.
C) In the WHERE condition, you use (+) following the name of the column in
the table without matching rows, to perform an outerjoin.

12. A view is which of the following?

A. A virtual table that can be accessed via SQL commands


B. A virtual table that cannot be accessed via SQL commands
C. A base table that can be accessed via SQL commands

13. The following are correct aggregate functions except:


A. MIN, MAX, SUM, COUNT
B. MEAN, SUM, AVG, COUNT
C. SUM, AVG, COUNT, MIN, MAX

14. Which of the following statements about view is false:


A. Views allows users to represent a subset of the data contained in a table
B. Users cannot query the view just as they would any real database table.
C. Views can be used as security mechanisms by letting users access data
through the view, without granting the users permissions to directly
access the underlying base tables of the view

15. Which of the following statement is false about NVL?


A. NVL is used to substitute a value when a null value is encountered
B. Users can apply NVL function to several columns within the same
function call.
C. When NVL is used with the DISTINCT clause, the DISTINCT clause
must come before the use of NVL function.

16. Which of the following statements is false about the HAVING clause?
A. The HAVING clause selects rows before grouping.
B. The HAVING clause can contain aggregate functions
C. The HAVING clause cannot be used without the GROUP BY clause.

17. If you don't specify ASC or DESC after a SQL ORDER BY clause, the
following is used by default?
A. ASC
B. DESC
C. There is no default value
18. Which of the following is false about group by:
A. Group by can be used on more than one column
B. The usage of SQL GROUP BY clause is, to divide the rows in a table
into smaller groups
C. The GROUP BY clause cannot be used without an aggregate function.

19. True or False: Stored procedure can call itself or recursive stored procedure. False

20. Which of the following is false about using Stored Procedures?


A. Stored procedures provide better security to your data.
B. Stored procedures can encapsulate logic. You can change stored
procedure code without affecting clients.
C. Stored procedure adds network traffic and latency.

You might also like