Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

MySQL Final Test

Total questions: 50

Worksheet time: 29mins

Name
Class
Date
1.

What does SQL stand for?

a)

Structured Query Language

b)

Structured Question Language

c)

Strong Question Language

d)

None of the above

2.

Which of the following can add a row to a table?

a)

Add

b)

Insert

c)

Update

d)

Alter

3.

What does DML stand for?

a)

Data Manipulation Language

b)

Data Modeling Language

c)

Data Markup Language

d)

Data Migration Language

4.

Which of the following query is correct to get Current Date from Query?

A. SELECT DATE ( NOW() ) as today;

B. SELECT DATE_FORMAT( NOW( ) , '%Y-%m-%d' ) as today;

a)

A. SELECT DATE ( NOW() ) as today;

b)

B. SELECT DATE_FORMAT( NOW( ) , '%Y-%m-%d' ) as today;

c)

Both A and B

d)

None

5.

Which of the following is not a valid aggregate function?

a)

COUNT

b)

MIN

c)

COMPUTE

d)

MAX

6.

The _________ statement is used to delete a table.

a)

DROP TABLE

b)

DELETE TABLE

c)

DEL TABLE

d)

REMOVE TABLE

7.

Which one of the following sorts rows in SQL?

a)

SORT BY

b)

ALIGN BY

c)

GROUP BY

d)

ORDER BY

8.

The SQL statement that queries or reads data from a table is __________ .

a)

USE

b)

SELECT

c)

READ

d)

QUERY

9.

Which SQL statement is used to return only different values?

a)

SELECT DISTINCT

b)

SELECT UNIQUE

c)

SELECT DIFF

d)

SELECT DIFFERENT

10.

With SQL, how do you select all the columns from a table named "Persons"?

a)

SELECT * FROM Persons

b)

SELECT Persons

c)

SELECT [all] FROM Persons

d)

SELECT *.Persons

11.

In a LIKE clause, you can ask for any 6 letter value by writing

a)

LIKE ______ (that's six underscore characters)

b)

LIKE ...... (that's six dots)

c)

LIKE .{6}

d)

LIKE ??????

12.

Which SQL statement is used to update data in a database?

a)

MODIFY

b)

ALTER

c)

SAVE

d)

UPDATE

13.

SQL can be used to:

a)

Create database structures only.

b)

Query database data only.

c)

Modify database data only.

d)

All of the above can be done by SQL.

14.

The SQL keyword BETWEEN is used:

a)

For ranges.

b)

To limit the columns displayed.

c)

As a wildcard.

d)

None of the above

15.

Which statement is used to delete an existing row from the table?

a)

DELETE

b)

WHERE

c)

MODIFY

d)

None of these

16.

Write a query to display first_name and last_name of all employees who have their first_name starting with 'A'.

a)

Select first_name from employess where first_name LIKE '%A';

b)

Select first_name from employess where first_name LIKE "'A'%";

c)

Select first_name from employess where first_name LIKE 'A%';

d)

Select first_name from employess where first_name LIKE '%A%';

17.

A relational database can have how many types of keys in a table ?

a)

Candidate key

b)

Primary key

c)

Foreign key

d)

All of these

18.

Which one of the following uniquely identifies the tuples/tows in a relation ?

a)

Secondary key

b)

Primary key

c)

Composite key

d)

Foreign key

19.

What is the full form of DDL ?

a)

Dynamic data language

b)

Detailed data language

c)

Data definition language

d)

Data derivation language

20.

Which of the following keywords will you use to display unique values of the column dept_name ?


SELECT ______ dept_name from COMPANY;

a)

All

b)

distinct

c)

from

d)

name

21.

INSERT INTO EMP VALUES(101,'SUMAN','MANAGER');


Which kind of statement is this ?

a)

DDL

b)

DML

c)

Value

d)

Python statement

22.

What will be the output for :-


SELECT LENGTH("EMPLOYEE");

a)

10

b)

8

c)

EMPLOYEE

d)

1

23.

What will be the output for :-


SELECT ROUND(153.669,2);

a)

153.6

b)

153.7

c)

153.67

d)

153.66

24.

What is the default sort order in ORDER BY clause?

a)

Ascending

b)

Descending

25.

What will be returned by the given query?

SELECT month('2020-05-11');

a)

5

b)

11

c)

May

d)

November

26.

Function TRIM() can remove leading and trailing text from a string

a)

True

b)

False

27.

The ______ keyword returns all records from the right table (table2), and the matching records (if any) from the left table (table1).

a)

INNER JOIN

b)

RIGHT JOIN

c)

EQUI JOIN

d)

NATURAL JOIN

28.

What is meaning of LIKE '%O%o%' ?

a)

Feature begins with two O's

b)

Feature ends with two o's

c)

Feature has more than two o's

d)

Feature has two O's in it, at any position

29.

A table has 3 columns. student_id, name, department. I need to insert only student_id and name. Which command is true

a)

insert into patient values(101,'Poorva')

b)

insert into patient(student_id,name) values(101,'Poorva')

c)

insert into patient(student_id,name) = (101,'Poorva')

d)

insert into patient values(101,'Poorva','')

30.

To store a name the data type is given as char(10). The name entered is Diya. How many characters will be used to store the name?

a)

4

b)

8

c)

10

31.

SQL is not case sensitive. SELECT is the same as select.

a)

TRUE

b)

FALSE

32.

Not equal to?

a)

>=

b)

<>

c)

=<

d)

<=

33.

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%’

34.

How do we select all rows for the "Designer" table?

a)

SELECT * FROM Designer

b)

SELECT [All] FROM Designer

c)

SELECT Designer.*

d)

SELECT FROM Designer

35.

Which statement allows us to add a record to a table?

a)

Add To

b)

Update To

c)

Add Into

d)

Insert Into

36.

The WHERE clause is only used in SELECT statements, it is not used in UPDATE, DELETE, etc

a)

TRUE

b)

FALSE

37.

A query is needed to display each department and its manager name from the above tables. However, not all departments have a manager but we want departments returned in all cases. Which of the following SQL: 1999 syntax scripts will accomplish the task?

a)

SELECT departments.department_id, employees.first_name, employees.last_name 

FROM employees 

RIGHT JOIN departments 

ON (employees.employee_id = departments.manager_id);

b)

SELECT departments.department_id, employees.first_name, employees.last_name 

FROM employees 

LEFT JOIN departments 

WHERE (employees.department_id = departments.department_id);

c)

SELECT departments.department_id, employees.first_name, employees.last_name 

FROM employees 

FULL JOIN departments 

ON (employees.employee_id = departments.manager_id);

d)

SELECT departments.department_id, employees.first_name, employees.last_name 

FROM employees , departments 

WHERE employees.employee_id 

RIGHT OUTER JOIN departments.manager_id;

38.

Identify Data Manipulation Language command

a)

Insert

b)

Use

c)

Update

d)

Select

39.
What is the difference between a left join and a right join?
a)

There is no difference between a left join and a right join.

b)

A left join returns all rows from the left table and matching rows from the right table, while a right join returns all rows from the left table and matching rows from the right table.

c)

A left join returns all rows from the left table and matching rows from the right table, while a right join returns all rows from the right table and matching rows from the left table.

d)

A left join returns only matching rows from the left table and the right table, while a right join returns only matching rows from the right table and the left table.

40.
What is a natural join?
a)
A join that includes only rows that have null values.
b)
A join that matches rows based on their common column names.
c)
A join that includes only rows that have non-null values.
d)
A join that matches rows based on a custom condition.
41.
Which normal form requires that every non-key attribute be fully functionally dependent on the primary key?
a)
First normal form (1NF)
b)
Second normal form (2NF)
c)
Third normal form (3NF)
d)
Fourth normal form (4NF)
42.
What is a subquery?
a)
A query that returns a single row and column.
b)
A query that returns a single row and multiple columns.
c)
A query that returns multiple rows and columns.
d)
A query that is embedded within another query.
43.
Which of the following is an example of a subquery in a SELECT statement?
a)
SELECT COUNT(*) FROM orders;
b)
SELECT * FROM customers WHERE age > 25;
c)
SELECT AVG(price) FROM products WHERE category = 'Electronics';
d)
SELECT * FROM orders WHERE customer_id IN (SELECT id FROM customers WHERE age > 25);
44.
Which normal form eliminates repeating groups by creating a separate table for each group?
a)
First Normal Form (1NF)
b)
Second Normal Form (2NF)
c)
Third Normal Form (3NF)
d)
Fourth Normal Form (4NF)
45.
Which of the following is a valid subquery?
a)
SELECT * FROM customers WHERE age > (SELECT age FROM employees);
b)
SELECT * FROM customers WHERE age = (SELECT name FROM employees);
c)
SELECT * FROM customers WHERE age = (SELECT COUNT(*) FROM employees);
d)
SELECT * FROM customers WHERE age = (SELECT AVG(age) FROM employees);
46.
Which of the following is not a valid subquery operator?
a)
IN
b)
EXISTS
c)
LIKE
d)
ALL
47.
Which of the following is an example of a correlated subquery?
a)
SELECT COUNT(*) FROM customers WHERE age > 25;
b)
SELECT AVG(price) FROM products WHERE category = 'Electronics';
c)
SELECT * FROM employees WHERE department = (SELECT name FROM departments WHERE id = 1);
d)
SELECT * FROM orders WHERE customer_id = (SELECT id FROM customers WHERE name = 'John Doe');
48.
Which normal form eliminates transitive dependencies by creating a separate table for each non-key attribute?
a)
First Normal Form (1NF)
b)
Second Normal Form (2NF)
c)
Third Normal Form (3NF)
d)
Fourth Normal Form (4NF)
49.

What is the result of the following SQL query: SELECT * FROM orders ORDER BY date DESC LIMIT 5;

a)

All orders will be returned in reverse chronological order.

b)

The 5 most recent orders will be returned in chronological order.

c)

The 5 oldest orders will be returned in chronological order.

d)

The 5 most recent orders will be returned in reverse chronological order.

50.

Which of the following SQL queries performs an equi join?

a)

SELECT * FROM customers JOIN orders ON customers.id = orders.customer_id;

b)

SELECT * FROM employees JOIN departments ON employees.department_id = departments.id;

c)

SELECT * FROM products LEFT JOIN categories ON products.category_id = categories.id;

d)

SELECT * FROM sales RIGHT JOIN products ON sales.product_id = products.id;