wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Database Reviewer

Total questions: 59

Worksheet time: 50mins

Name
Class
Date
1.

You need to disable User1’s access to view the data in the Customer table. Which statement should you use?

a)

REVOKE User1 FROM Customer

b)

REMOVE User1 FROM Customer

c)

REMOVE SELECT ON Customer FROM User1

d)

REVOKE SELECT ON Customer FROM User1

2.

You have a Department table and an Employee table in your database. You need to ensure that an employee can be assigned to only an existing department. What should you apply to the Employee table?

a)

A data type

b)

An index

c)

A foreign key

d)

A unique constraint

e)

A primary key

3.

Which SQL statement will return the country and number of orders in each country where the number of orders is less than 50? orderID represents an individual order, Country represents the country, and Orders represent the number of orders.

a)

SELECT Country, orderID FROM Orders GROUP BY Country WHERE COUNT(orderID) < 50

b)

SELECT COUNT (OrderID), Country FROM Orders GROUP BY Country HAVING COUNT (orderID) < 50

c)

SELECT Country, orderID FROM Orders HAVING COUNT (orderID)

d)

SELECT COUNT (OrderID), Country FROM Orders HAVING COUNT (orderID) < 50 GROUP BY Country

4.

For each of the following statements, select True if the statement is true. Otherwise, select False. Each correct selection is worth a partial point. (True or False)

(a)  

5.

A transaction log backup backs up all the data in the database (True or False)

(a)  

6.

A differential backup copies only data that was changed before the last full backup (false or false)

(a)  

7.

A file or filegroup restore specified a portion of the database to recover (True or False)

(a)  

8.

You create a table names Games that contains the review scores of recently released video games. You need to create a view that returns an alphabetical list of game names. Name represents the game name. Which query should you use?

a)

CREATE VIEW MyGame AS SELECT Name FROM Games ORDER BY Name

b)

CREATE VIEW MyGame AS SELECT * FROM Games

c)

CREATE VIEW MyGame AS SELECT Name FROM Games

d)

CREATE VIEW MyGame AS SELECT * from Games WHERE Name BETWEEN ‘A’ AND ‘I’

9.

Your database contains a table named Customer. You need to delete the record from the Customer table that has a CustomerID of 12345. Which statement should you use?

a)

DELETE FROM Customer WHERE CustomerID = 12345

b)

UPDATE Customer DELETE * WHERE CustomerID = 12345

c)

DELETE CustomerID FROM Customer WHERE CustomerID = 12345

d)

UPDATE CustomerID FROM Customer DELETE * WHERE CustomerID = 12345

10.

Each value in a field in a table must be unique

a)

True

b)

False

11.

Each row in a table must be unique

a)

True

b)

False

12.

Each column name in a table must be unique

a)

True

b)

False

13.

You need to remove a view named EmployeeView from your database. Which statement should you use?

a)

DROP EmployeeView

b)

DELETE VIEW EmployeeView

c)

DELETE EmployeeView

d)

DROP VIEW EmployeeView

14.

What database term is used to describe the relationship between ProductID and ProductCategory?

a)

Deterministic

b)

Compositional

c)

Relatively dependent

d)

Functionally dependent

e)

Cohort

15.

Answer the Following.

15.

Answer:

(a)  

16.

You need to recommend a data type in a database table to run financial functions against the charged amounts. Which data type should you recommend?

a)

Varchar

b)

Binary

c)

Bit

d)

Decimal

17.

17.

Which two columns should you select? (Choose 2)

a)

LanguageID

b)

LanguageName

c)

Country

d)

Region

e)

ChapterID

18.

You execute the following statement. INSERT INTO Road VALUES (1234, 36) What is the result?

a)

A syntax error

b)

An error stating that NULL values are not allowed

c)

A new row in the table

d)

An error stating that duplicate IDs are not allowed

19.

Which keyword combines the results of two queries and returns only rows that appear in both result sets?

a)

JOIN

b)

INTERSECT

c)

ALL

d)

UNION

20.

You need to create a report of data in the student’s table. The report must meet the following requirements:

• Display all students who enrolled on or after June 1, 2020

• Display all students who graduated in 2022.

• Return the result set in order of enrollment, with the most recent enrollment date first.

enrollment_date specifies the enrollment date.

graduation date specifies the graduation date.

an academic status of Graduated indicates that a student has graduated.

a)

WHERE enrollment_date >= ‘2020-06-01’ AND academic_status = ‘Graduated’ AND graduation_date >= ‘2020-01-01’ ORDER BY enrollment_date ASC

b)

SELECT * FROM students WHERE enrollment_date >= ‘2020-06-01’ AND academic_status = ‘Graduated’ OR graduation_date >= ‘2020-01-01’ ORDER BY enrollment_date

c)

SELECT * FROM students WHERE enrollment_date >= ‘2020-06-01’ OR academic_status = ‘Graduated’ AND graduation_date >= ‘2020-01-01’ ORDER BY enrollment_date DESC

d)

SELECT * FROM students WHERE enrollment_date >= ‘2020-06-01’ OR academic_status = ‘Graduated’ OR graduation_date >= ‘2020-01-01’ ORDER BY enrollment_date DESC

21.

This type of operation is called a/an:

a)

Outer join

b)

Equi-join

c)

Intersection

d)

Cartesian product

22.

You have a Customer table that stores information about customers and anOrder table that stores information about orders placed. Each table contains a CustomerID column. You join the two tables by using the CustomerID column in each table.

You run a query that selects the following data:

• All customers and their orders

• Customers who have no orders

Which type of join do these results represent?

a)

Complete join

b)

Partial join

c)

Inner join

d)

Full join

23.

You need to create a database to provide a view of North America mammals (NorthAmericanMammals_View). Drag the code segments from the list on the left to the correct locations on the right. You may use each code segment once, more than once, or not at all.

Code Segments

a) CREATE VIEW (dbo) . (NorthAmericanMammals_View)

b) UPDATE VIEW (dbo) . (NorthAmericanMammals_View)

c) AS SELECT a.Id, a.Name

d) AS SELECT VIEW a.Id, a.Name

e) FROM Animal a

f) FROM Animal b

Answer Segments:

Blank-1

Blank-2

Blank-3

WHERE a.Class = 'Mammals'

AND a.InNorthAmerica = 1

a)

A, C, and E

b)

B, D, and E

c)

B, D, and C

d)

A, E, and B

24.

Your company stores customer social security numbers in a column named SSN in a table named Customers. New compliance laws prohibit your company from storing this information. Running the query below causes an error to occur.

ALTER TABLE Customers REMOVE SSN;

What changes are needed to the query above so that if removes the SSN column from the Customers table?

a)

ALTER TABLE Customers DELETE SSN;

b)

ALTER TABLE Customers DROP SSN;

c)

ALTER TABLE Customers DROP COLUMN SSN;

d)

ALTER TABLE Customers DELETE COLUMN SSN;

25.

Another developer is trying to add a column named Prefix in a table by using the following query:

ALTER TABLE Person ADD Prefix varchar(4) NOT NULL;

The developer receives an error message after running the query. The developer is unable to remember the exact error message. What is likely the cause of this problem?

a)

The varchar(4) data type is invalid for the Person table

b)

You should run the DROP CONSTRAINT query before running the ALTER TABLE query

c)

The Person table is empty

d)

The DEFAULT keyword should be used to specify a default value

26.

Which statement will correctly update your table?

a)

UPDATE LoanedBooks SET Books = 0 WHERE (NAME = ‘Harry’ or City = ‘San Francisco’)

b)

UPDATE LoanedBooks SET Books = 0 WHERE (NAME In ‘Harry’, ‘San Francisco’)

c)

UPDATE LoanedBooks SET Books = 0 WHERE (NAME = ‘Harry’ AND City = ‘San Francisco’)

d)

INSERT INTO LoanedBooks SET Books = 0 WHERE ID = 4

27.

Which syntax should you use to create the object?

a)

CREATE TABLE (ID INT, Name VARCHAR (100), Age INT)

b)

CREATE (TABLE Student ID INT, Name VARCHAR (100), Age INT)

c)

CREATE TABLE Student (ID INT, Name VARCHAR (100), Age INT)

d)

CREATE Student (ID INT, Name VARCHAR (100), Age INT)

28-30.

28.

What is the correct data type for StudentName field?

a)

BIT

b)

DECIMAL

c)

CHAR

d)

VARCHAR

29.

What is the appropriate data type for GradeLevel

a)

DECIMAL

b)

INT

c)

BIT

d)

VARCHAR

30.

What is the appropriate data type for DaysAbsent?

a)

DECIMAL

b)

INT

c)

BIT

d)

VARCHAR

31.

What should you do?

a)

Remove the GROUP BY clause

b)

Remove the ORDER BY clause

c)

Change the HAVING clause to HAVING COUNT(Title)= 1

d)

Change the HAVING clause to HAVING COUNT (1) = 1

32.

Which query correctly runs a result set for all orders where the ship_state excludes Texas (TX) and Arizona (AZ)?

a)

SELECT * FROM Orders WHERE ship_state NOT = ‘TX’ OR ship_state NOT = ‘AZ’

b)

SELECT * FROM Orders WHERE ship_state NOT = ‘TX’ AND ship_state NOT = ‘AZ’

c)

SELECT * FROM Orders WHERE NOT ship_state = ‘TX’ OR NOT ship_state = ‘AZ’

d)

SELECT * FROM Orders WHERE NOT ship_state = ‘TX’ AND NOT ship_state = ‘AZ’

33.

Which statement creates an index?

a)

CREATE TABLE Employee (EmployeeID INTEGER PRIMARY KEY)

b)

CREATE TABLE Employee (EmployeeID INTEGER INDEX)

c)

CREATE TABLE Employee (EmployeeID INTEGER NULL)

d)

CREATE TABLE Employee (EmployeeID INTEGER DISTINCT)

34.

Which query should you use?

a)

SELECT COUNT(ID), AVG(UnitPrice+Quantity), MAX(UnitPrice+Quantity), SUM(UnitPrice+Quantity) FROM ItemsOnOrder, GROUP BY ItemNumber, LineItemTotal

b)

SELECT COUNT(ID), AVG(LineItemTotal), MAX(LineItemTotal), SUM(LineItemTotal) FROM ItemsOnOrder HAVING ItemNumber, Quantity, UnitPrice

c)

SELECT COUNT(ID), AVG(LineItemTotal), MAX(LineItemTotal), SUM(LineItemTotal) FROM ItemsOnOrder

d)

SELECT SUM(ID), AVG(LineItemTotal), MAX(LineItemTotal), SUM(LineItemTotal) FROM ItemsOnOrder

35.

You are writing a SELECT statement to find every product whose name contains a specific character. Which keyword should you use in your WHERE clause?

a)

BETWEEN

b)

FETCH

c)

LIKE

d)

IN

36.

What will make this type of search more efficient?

a)

A clustered index on the Price column

b)

A non-clustered index on the Price column

c)

A non-clustered index on the Category column

d)

A clustered index on the ProductName column

37.

You have two tables named SalesPerson and Sales. You need to ensure that each record in the Sales table has a valid associated salesperson record in the SalesPerson table. Which database object should you add to the Sales table?

a)

Clustered index

b)

Foreign key

c)

Primary key

d)

Non-clustered index

38.

You are developing a SQL statement to create a table. Which two SQL keywords are valid to use in a CREATE TABLE statement? (Choose 2)

a)

PRIMARY KEY

b)

CONSTRAINT

c)

INSERT INTO

d)

ORDER BY

39.

You delete rows in a table named Order. The corresponding rows in theOrderItem table are automatically deleted. This process is an example of a/an:

a)

Inherited delete

b)

Waterfall delete

c)

Domino delete

d)

Cascade delete

e)

Functional delete

40.

How many rows are returned by the SQL statement?

a)

7

b)

4

c)

6

d)

5

41.

You must update the table when volunteers ask to be removed from mailing lists. You need to delete all records with the GivenName Tia. Which SQL statement should you use?

a)

DELETE FROM Volunteer WHERE GivenName = ‘Tia’

b)

DELETE FROM Volunteer WHERE GivenName EQUALS ‘Tia’

c)

DELETE FROM Volunteer WHERE GivenName IS ‘Tia’

d)

DELETE FROM Volunteer WHERE GivenName==’Tia’

42.

You have a table named Employee that includes the following columns:

EmployeeID

EmployeeName

Which statement should you use to return the number of rows in the table?

a)

SELECT SUM(*) FROM Employee

b)

SELECT * FROM Employee

c)

SELECT COUNT(rows) FROM Employee

d)

SELECT COUNT(*) FROM Employee

43.

Which query will retrieve ItemName and Price when chocolate appears in the ItemDescription column?

a)

SELECT ItemName, Price FROM Products WHERE ItemDescription LIKE ‘%chocolate%’;

b)

SELECT ItemName, Price FROM Products WHERE ItemDescription IN ‘%chocolate%’;

c)

SELECT ItemName, Price FROM Products WHERE ItemDescription = ‘chocolate’;

d)

SELECT ItemName, Price FROM Products WHERE ItemDescription LIKE ‘chocolate’;

44.

Which statement deletes the rows where the employer’s phone number is not entered?

a)

DELETE FROM Employee WHERE Phone = NULL

b)

DELETE FROM Employee WHERE Phone IS NOT NULL

c)

DELETE FROM Employee WHERE Phone = NULLABLE

d)

DELETE FROM Employee WHERE Phone IS NULL

45.

Which feature does a relational database use to ensure that data entered into a column is valid?

a)

An index

b)

A primary key

c)

A constraint

d)

An attribute

46.

You have a table named Product. The Product table has columns for ProductDescription and ProductCategory. You need to change the ProductCategory value for all the spoons in the Product table to 43. A ProductDescription of spoon indicates that the item is a spoon. Which statement should you use?

a)

SET Product TO ProductCategory = 43 WHERE ProductDescription = ‘spoon’

b)

UPDATE Product SET ProductCategory = 43 WHERE ProductDescription = ‘spoon’

c)

SET Product WHERE ProductDescription = ‘spoon’ TO ProductCategory = 43

d)

UPDATE Product WHERE ProductDescription = ‘spoon’ SET ProductCategory = 43

47.

You have a table name Product. You create a view that includes all the products from the Product table that are in the Furniture category. You execute a statement on the Product table that deletes all the products in the Furniture category. After you execute the statement, the result set of the view is:

a)

Deleted

b)

Archived

c)

Empty

d)

Unchanged

48.

A table has clustered index. Complete the statements by selecting the correct option from each drop-down list.

a)

A clustered index improves the performance of queries that _____

b)

A clustered index improves the performance of queries on columns that ____

c)

Return large results sets

d)

are accessed randomly

49.

You execute a statement inside a transaction to delete 100 rows from a table. The transaction fails after only 40 rows are deleted. What is the result in the database?

a)

The table will be corrupted

b)

No rows will be deleted form the table

c)

The transaction will restart

d)

40 rows will be deleted form the table

50-52.

50.

Blank 1

a)

PhoneNumber

b)

WHERE

c)

GROUP BY

d)

ORDER BY

51.

Blank 2

a)

IS NOT NULL

b)

WHERE

c)

ORDER BY

d)

GROUP BY

52.

Blank 3

a)

ORDER BY

b)

PhoneNumber

c)

GROUP BY

d)

INSERT

53.

Which query will increase the price of item 1 by 6 percent?

a)

ALTER Products SET Price = Price * 1.06 WHERE ItemNumber = 1;

b)

USE Products SET Price = Price * 1.06 WHERE ItemNumber = 1;

c)

UPDATE Products SET Price = Price * 1.06 WHERE ItemNumber = 1;

d)

SET Price = Price * 1.06 FROM Products WHERE ItemNumber = 1;

54.

One reason to create a stored procedure is to:

a)

Improve performance

b)

Bypass case sensitivity requirements

c)

Give the user control of the query log

d)

Minimize storage space

55.

You need to normalize a database to first normal form. Which two requirements must you meet? (Choose two)

a)

Exclude repeating groups

b)

) Exclude foreign keys

c)

Exclude duplicate rows

d)

Exclude composite keys

56.

Which SQL statement is a data manipulation language (DML) statement?

a)

SELECT * INTO Employee FROM NewHires

b)

ALTER TABLE Employee ADD EmployeeName VARCHAR

c)

SELECT EmployeeName FROM Employee WHERE EmployeeName = ‘Jack Smith’;

d)

INSERT INTO Employee VALUES (‘Jack Smith’);

57.

You have a table named Customer that has columns named CustomerID, Firstname, and DateJoined CustomerID is a primary key. You execute the following query:

SELECT CustomerID, FirstName, DateJoined FROM Customer

How are the rows organized in the result set?

a)

In no predictable order

b)

In alphabetical order by FirstName

c)

In the order in which the rows were inserted

d)

In chronological order by DateJoined

58-60.

58.

Blank 1

a)

TOP 10

b)

GROUP BY 10

c)

COUNT

d)

IS NULL

59.

Blank 2

a)

IS NOT NULL

b)

IS NULL

c)

GROUP BY 10

d)

ORDER BY

60.

Blank 3

a)

GROUP BY 10

b)

ORDER BY

c)

TOP 10

d)

COUNT

61.

The stored procedure returns all null value. You verify that there is data in the Person table. What is like the cause of this problem?

a)

The plus (+) operator cannot be used to append character data

b)

You must specify the NULLIF keyword in the query

c)

You must specify the JOIN keyword in the SELECT statement

d)

The Prefix or firstName columns have null values

62.

You need to populate a table named EmployeeCopy with data from an existing table named Employee. Which statement should you use?

a)

FROM Employee INTO EmployeeCopy

b)

INSERT INTO EmployeeCopy SELECT * FROM Employee

c)

SELECT INTO EmployeeCopy SELECT FROM Employee

d)

COPY INTO Employee SELECT FROM Employee

63.

Which statement should you use to remove a foreign key?

a)

DELETE TABLE

b)

DELETE FOREGIN KEY

c)

ALTER TABLE

d)

ALTER FOREIGN KEY

64-67.

64.

Blank 1

a)

AND

b)

OR

c)

WHERE

d)

ORDER BY

65.

Blank 2

a)

>

b)

<

c)

=

d)

ORDER BY

66.

Blank 3

a)

ORDER BY

b)

GROUP BY

c)

AND

d)

WHERE

67.

Blank 4

a)

ArrivalTime DESC

b)

OriginAirport

c)

Arrival Time

d)

DepartureTime

68.

Which statement creates a composite key?

a)

CREATE TABLE Order (OrderID INTEGER , OrderItemID INTEGER, PRIMARY KEY (OrderID, OrderItemID))

b)

CREATE TABLE Order (OrderID INTEGER, OrderItemID INTEGER, PRIMARY KEY OrderID, PRIMARY KEY OrderItemID))

c)

CREATE TABLE Order (OrderID INTEGER, OrderItemID INTEGER, PRIMARY KEY)

d)

CREATE TABLE Order (OrderID INTEGER PRIMARY KEY, OrderItemID INTEGER PRIMARY KEY)