WorksheetsMySQL Final Test
Total questions: 50
Worksheet time: 29mins
What does SQL stand for?
Structured Query Language
Structured Question Language
Strong Question Language
None of the above
Which of the following can add a row to a table?
Add
Insert
Update
Alter
What does DML stand for?
Data Manipulation Language
Data Modeling Language
Data Markup Language
Data Migration Language
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. SELECT DATE ( NOW() ) as today;
B. SELECT DATE_FORMAT( NOW( ) , '%Y-%m-%d' ) as today;
Both A and B
None
Which of the following is not a valid aggregate function?
COUNT
MIN
COMPUTE
MAX
The _________ statement is used to delete a table.
DROP TABLE
DELETE TABLE
DEL TABLE
REMOVE TABLE
Which one of the following sorts rows in SQL?
SORT BY
ALIGN BY
GROUP BY
ORDER BY
The SQL statement that queries or reads data from a table is __________ .
USE
SELECT
READ
QUERY
Which SQL statement is used to return only different values?
SELECT DISTINCT
SELECT UNIQUE
SELECT DIFF
SELECT DIFFERENT
With SQL, how do you select all the columns from a table named "Persons"?
SELECT * FROM Persons
SELECT Persons
SELECT [all] FROM Persons
SELECT *.Persons
In a LIKE clause, you can ask for any 6 letter value by writing
LIKE ______ (that's six underscore characters)
LIKE ...... (that's six dots)
LIKE .{6}
LIKE ??????
Which SQL statement is used to update data in a database?
MODIFY
ALTER
SAVE
UPDATE
SQL can be used to:
Create database structures only.
Query database data only.
Modify database data only.
All of the above can be done by SQL.
The SQL keyword BETWEEN is used:
For ranges.
To limit the columns displayed.
As a wildcard.
None of the above
Which statement is used to delete an existing row from the table?
DELETE
WHERE
MODIFY
None of these
Write a query to display first_name and last_name of all employees who have their first_name starting with 'A'.
Select first_name from employess where first_name LIKE '%A';
Select first_name from employess where first_name LIKE "'A'%";
Select first_name from employess where first_name LIKE 'A%';
Select first_name from employess where first_name LIKE '%A%';
A relational database can have how many types of keys in a table ?
Candidate key
Primary key
Foreign key
All of these
Which one of the following uniquely identifies the tuples/tows in a relation ?
Secondary key
Primary key
Composite key
Foreign key
What is the full form of DDL ?
Dynamic data language
Detailed data language
Data definition language
Data derivation language
Which of the following keywords will you use to display unique values of the column dept_name ?
SELECT ______ dept_name from COMPANY;
All
distinct
from
name
INSERT INTO EMP VALUES(101,'SUMAN','MANAGER');
Which kind of statement is this ?
DDL
DML
Value
Python statement
What will be the output for :-
SELECT LENGTH("EMPLOYEE");
10
8
EMPLOYEE
1
What will be the output for :-
SELECT ROUND(153.669,2);
153.6
153.7
153.67
153.66
What is the default sort order in ORDER BY clause?
Ascending
Descending
What will be returned by the given query?
SELECT month('2020-05-11');
5
11
May
November
Function TRIM() can remove leading and trailing text from a string
True
False
The ______ keyword returns all records from the right table (table2), and the matching records (if any) from the left table (table1).
INNER JOIN
RIGHT JOIN
EQUI JOIN
NATURAL JOIN
What is meaning of LIKE '%O%o%' ?
Feature begins with two O's
Feature ends with two o's
Feature has more than two o's
Feature has two O's in it, at any position
A table has 3 columns. student_id, name, department. I need to insert only student_id and name. Which command is true
insert into patient values(101,'Poorva')
insert into patient(student_id,name) values(101,'Poorva')
insert into patient(student_id,name) = (101,'Poorva')
insert into patient values(101,'Poorva','')
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?
4
8
10
SQL is not case sensitive. SELECT is the same as select.
TRUE
FALSE
Not equal to?
>=
<>
=<
<=
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”?
SELECT * FROM Persons WHERE FirstName=’a’
SELECT * FROM Persons WHERE FirstName LIKE ‘a%’
SELECT * FROM Persons WHERE FirstName LIKE ‘%a’
SELECT * FROM Persons WHERE FirstName=’%a%’
How do we select all rows for the "Designer" table?
SELECT * FROM Designer
SELECT [All] FROM Designer
SELECT Designer.*
SELECT FROM Designer
Which statement allows us to add a record to a table?
Add To
Update To
Add Into
Insert Into
The WHERE clause is only used in SELECT statements, it is not used in UPDATE, DELETE, etc
TRUE
FALSE
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?
SELECT departments.department_id, employees.first_name, employees.last_name
FROM employees
RIGHT JOIN departments
ON (employees.employee_id = departments.manager_id);
SELECT departments.department_id, employees.first_name, employees.last_name
FROM employees
LEFT JOIN departments
WHERE (employees.department_id = departments.department_id);
SELECT departments.department_id, employees.first_name, employees.last_name
FROM employees
FULL JOIN departments
ON (employees.employee_id = departments.manager_id);
SELECT departments.department_id, employees.first_name, employees.last_name
FROM employees , departments
WHERE employees.employee_id
RIGHT OUTER JOIN departments.manager_id;
Identify Data Manipulation Language command
Insert
Use
Update
Select
There is no difference between a left join and a right join.
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.
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.
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.
What is the result of the following SQL query: SELECT * FROM orders ORDER BY date DESC LIMIT 5;
All orders will be returned in reverse chronological order.
The 5 most recent orders will be returned in chronological order.
The 5 oldest orders will be returned in chronological order.
The 5 most recent orders will be returned in reverse chronological order.
Which of the following SQL queries performs an equi join?
SELECT * FROM customers JOIN orders ON customers.id = orders.customer_id;
SELECT * FROM employees JOIN departments ON employees.department_id = departments.id;
SELECT * FROM products LEFT JOIN categories ON products.category_id = categories.id;
SELECT * FROM sales RIGHT JOIN products ON sales.product_id = products.id;
