wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Database Practice Test 1 Review

Total questions: 13

Worksheet time: 11mins

Name
Class
Date
1.

Which SQL statement correctly retrieves a list of customers from Utah, sorted by last name?

a)

SELECT lastname, firstname FROM customers WHERE state = 'UT' ORDER BY lastname;

b)

SELECT lastname, firstname FROM customers ORDER BY lastname WHERE state = 'UT';

c)

SELECT lastname, firstname FROM customers WHERE state = 'UT' GROUP BY lastname;

d)

SELECT lastname, firstname FROM customers ORDER BY lastname;

2.

Which of the following statements about the GROUP BY clause are true?

a)

Yes, No, No

b)

No, Yes, No

c)

Yes, Yes, No

d)

No, No, Yes

3.

What is the issue with the following SQL statement? SELECT LastName, FirstName, COUNT(OrderID) FROM Customers GROUP BY LastName HAVING COUNT(OrderID) >= 5;

a)

The SQL statement is missing a GROUP BY clause for all selected columns.

b)

The HAVING clause is incorrectly used instead of WHERE.

c)

The COUNT function is used incorrectly with non-aggregated columns.

d)

The SQL statement is correct and has no issues.

4.

What would cause a runtime error in the following SQL statement? sql CopyEdit UPDATE Customers SET Status = 'Gold' IF TotalAmount > 10000;

a)

The object type needs to be specified within the UPDATE statement.

b)

The IF clause needs to be at the beginning of the statement.

c)

The IF clause needs to be a WHERE clause.

d)

The statement needs semicolons.

5.

Which SQL statement allows inserting multiple rows at once using the VALUES keyword?

a)

INSERT INTO table_name VALUES (value1, value2, value3,...);

b)

INSERT INTO table_name SELECT (column1, column2, column3);

c)

INSERT INTO table_name(column1, column2) VALUES (value1a, value1b), (value2a, value2b);

d)

INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...);

6.

A quality control specialist wants to retrieve an orderID after inputting an orderdetailID. Which of the following SQL statements correctly creates the required stored procedure?

a)

CREATE PROCEDURE uspGetOrderID @orderdetailIID int, @orderID int OUTPUT BEGIN SELECT @orderID = orderid FROM orderdetails WHERE orderdetailid = @orderdetailID END

b)

CREATE PROCEDURE uspGetOrderID @orderdetailIID int, @orderID int OUTPUT AS BEGIN SELECT orderid FROM orderdetails WHERE orderdetailid = @orderdetailID RETURN @orderID END

c)

CREATE PROCEDURE uspGetOrderID @orderdetailIID int AS BEGIN SELECT orderid FROM orderdetails WHERE orderdetailid = @orderdetailID END

d)

CREATE PROCEDURE uspGetOrderID @orderdetailIID int, @orderID int OUTPUT AS BEGIN SELECT @orderID = orderid FROM orderdetails WHERE orderdetailid = @orderdetailID END

7.

What is the correct SQL statement to create a stored procedure that retrieves an order ID based on the order detail ID?

a)

CREATE PROCEDURE uspGetOrderID @orderdetailID int, @orderID int OUTPUT AS BEGIN SELECT @orderID = orderid FROM orderdetails WHERE orderdetailid = @orderdetailID END

b)

CREATE PROCEDURE uspGetOrderID @orderdetailID int, @orderID int OUTPUT AS BEGIN SELECT orderid FROM orderdetails WHERE orderdetailid = @orderdetailID END

c)

CREATE PROCEDURE uspGetOrderID @orderdetailID int, @orderID int OUTPUT AS BEGIN SELECT @orderID = orderid FROM orderdetails WHERE orderdetailid = @orderdetailID RETURN @orderID END

d)

CREATE PROCEDURE uspGetOrderID @orderdetailID int, @orderID int OUTPUT AS BEGIN SELECT @orderID = orderid FROM orderdetails WHERE orderdetailid = @orderdetailID END

8.

A list of students volunteering at a Science Fair is stored in the Students table. If Benjamin is no longer attending and is replaced by Kayden, which SQL statement correctly updates the table?

a)

REPLACE INTO Students (FirstName) VALUES ('Kayden') WHERE FirstName = 'Benjamin';

b)

UPDATE Students SET FirstName = 'Kayden' WHERE FirstName = 'Benjamin';

c)

MODIFY Students SET FirstName = 'Kayden' WHERE FirstName = 'Benjamin';

9.

What is the purpose of the following SQL statement? INSERT INTO Students (FirstName) VALUES ('Kayden') WHERE FirstName = 'Benjamin';

a)

To add a new record with the name 'Kayden'

b)

To update the name 'Benjamin' to 'Kayden'

c)

To delete the record with the name 'Benjamin'

d)

To select the record with the name 'Benjamin'

10.

What is being enforced using this SQL statement? ALTER TABLE salesterritory ADD CONSTRAINT fk_location FOREIGN KEY (locationID) REFERENCES locations(locationID);

a)

Primary key

b)

Foreign key

c)

Referential integrity

d)

Compound key

11.

A student database contains multiple records with the same last name "Smith" and first name "David." If these records are not duplicates, how does the database differentiate them?

a)

By using unique student IDs

b)

By using different last names

c)

By using different first names

d)

By using different addresses

12.

What uniquely identifies each record in a table, ensuring that no two records share the same identifier, even if they have identical first and last names?

a)

Schema

b)

Foreign key

c)

Referential integrity

d)

Primary key

13.

What will be the result of the following SQL statement? CREATE VIEW cambridge_data AS SELECT NoControl, FullName FROM cambridge ORDER BY FullName;

a)

A SQL Server Database Error because the same column cannot be used multiple times in the statement.

b)

The creation of a view called cambridge_data with the data ordered by FullName.

c)

A SQL Server Database Error because the ORDER BY clause is not valid in the creation of a view.

d)

A SQL Server Database Error because the CREATE VIEW statement is not within a BEGIN/END block.