wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Database Practice Test 1 Part 2 Review

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which SQL query will list every product with every location?

a)

SELECT product FROM products CROSS JOIN location FROM locations;

b)

SELECT product FROM products LEFT OUTER JOIN location FROM locations ON products.product = locations.location;

c)

SELECT product FROM products FULL OUTER JOIN location FROM locations ON products.product = locations.location;

d)

SELECT product FROM products INNER JOIN location FROM locations ON products.product = locations.location;

2.

Which of the following SQL statements correctly defines a composite key?

a)

CREATE TABLE Signups ( studentID varchar(5) UNIQUE NOT NULL, classID varchar(5) UNIQUE NOT NULL, signupdate DATETIME, PRIMARY KEY (studentID, classID) );

b)

CREATE TABLE Signups ( studentID varchar(5) UNIQUE NOT NULL, classID varchar(5) UNIQUE NOT NULL, signupdate DATETIME, COMPOSITE KEY (studentID, classID) );

c)

CREATE TABLE Signups ( studentID varchar(5) UNIQUE NOT NULL, classID varchar(5) UNIQUE NOT NULL, signupdate DATETIME, PRIMARY KEY studentID, PRIMARY KEY classID );

d)

CREATE TABLE Signups ( studentID varchar(5) UNIQUE NOT NULL, classID varchar(5) UNIQUE NOT NULL, signupdate DATETIME, PRIMARY KEYS (studentID, classID) );

3.

Which SQL statement retrieves customers with sales of at least $50,000 from Los Angeles, California, Nevada, or Arizona?

a)

SELECT lastname, firstname FROM customers WHERE sales >=50000 OR ((city='Los Angeles' AND state='California') OR state IN ('Nevada','Arizona'));

b)

SELECT lastname, firstname FROM customers WHERE sales >50000 AND ((city='Los Angeles' AND state='California') OR state IN ('Nevada','Arizona'));

c)

SELECT lastname, firstname FROM customers WHERE sales >=50000 AND ((city='Los Angeles' AND state='California') OR state IN ('Nevada','Arizona'));

d)

SELECT lastname, firstname FROM customers WHERE sales >50000 OR ((city='Los Angeles' AND state='California') AND state IN ('Nevada','Arizona'));

4.

What SQL statement grants execution permissions on a stored procedure?

a)

GRANT EXECUTE ON sp_current_sales TO inside_sales;

b)

GRANT EXECUTE ON sp_current_sales TO GROUP inside_sales;

c)

GRANT EXECUTE ON sp_current_sales TO inside_sales WITH GRANT OPTION;

5.

Which SQL query correctly calculates the sales tax for customers with orders?

a)

SELECT firstname, lastname, subtotal, subtotal * 1.05 AS sales_tax FROM customers INNER JOIN orders ON customers.customerid = orders.customerid;

b)

SELECT firstname, lastname, subtotal, subtotal * 1.05 AS sales_tax FROM customers INNER JOIN orders ON customers.customerid = orders.customerid;

c)

SELECT firstname, lastname, subtotal, subtotal 1* .05 AS sales_tax FROM customers LEFT OUTER JOIN orders ON customers.customerid = orders.customerid;

6.

What is the correct SQL query to create a phone directory with unique numeric IDs?

a)

CREATE TABLE phone_directory (id INT UNIQUE, name VARCHAR(255), phone_number VARCHAR(15));

b)

CREATE TABLE phone_directory (id INT, name VARCHAR(255), phone_number VARCHAR(15));

c)

CREATE TABLE phone_directory (id INT PRIMARY KEY, name VARCHAR(255), phone_number VARCHAR(15));

d)

CREATE TABLE phone_directory (id INT NOT NULL, name VARCHAR(255), phone_number VARCHAR(15));

7.

Which is a major difference between a stored procedure and a function?

a)

A) A function must be compiled every time it is called.

b)

B) A stored procedure must be compiled every time it is called.

c)

C) Functions cannot be called from a stored procedure, but a stored procedure can be called from a function.

d)

D) A function can have both input/output parameters, but a stored procedure can only have input parameters.

8.

Evaluate the following table and query: ID | LastName | Salary 1 | Gomez | 83000 2 | Parker | 38000 3 | Smith | 70000 4 | Tang | 68000 Query: SELECT MAX(Salary) FROM employee; What is the output?

a)

A) 83000

b)

B) 1

c)

C) Gomez

d)

D) 38000

9.

What is the purpose of the `JOIN` statement in SQL?

a)

To delete records from a table

b)

To insert new records into a table

c)

To update records in a table

d)

To combine rows from two or more tables, based on a related column between them

10.

What type of join returns all records from the left table and the matched records from the right table?

a)

INNER JOIN

b)

LEFT JOIN

c)

RIGHT JOIN

d)

FULL JOIN