MySQL Quiz
MySQL is one of the most widely used relational databases. The questions cover SQL commands, data types, keys, joins, constraints and basic database administration.
What this quiz covers
- SELECT, INSERT, UPDATE and DELETE
- Primary and foreign keys
- Joins and constraints
- Data types and functions
Study tip: Practise by writing the query first and checking your result against the explanation, especially for joins.
Questions, answers and explanations
1. What is MySQL?
- A Programming Language
- A Relational Database Management System
- A CSS Framework
- A JavaScript Library
Answer: A Relational Database Management System
MySQL is one of the world's most popular relational database management systems.
2. Which language is used to interact with MySQL databases?
- HTML
- SQL
- CSS
- Python
Answer: SQL
SQL (Structured Query Language) is used to manage and query MySQL databases.
3. Who originally developed MySQL?
- Oracle
- MySQL AB
- Microsoft
Answer: MySQL AB
MySQL was originally developed by the Swedish company MySQL AB.
4. Which command is used to create a new database?
- CREATE DATABASE
- NEW DATABASE
- ADD DATABASE
- MAKE DATABASE
Answer: CREATE DATABASE
The CREATE DATABASE statement creates a new database.
5. Which SQL statement retrieves data from a table?
- GET
- SELECT
- SHOW
- DISPLAY
Answer: SELECT
The SELECT statement retrieves records from one or more tables.
6. Which SQL statement inserts a new record into a table?
- INSERT INTO
- ADD RECORD
- NEW ROW
- UPDATE
Answer: INSERT INTO
INSERT INTO adds new records to a table.
7. Which SQL statement updates existing records?
- CHANGE
- UPDATE
- MODIFY
- EDIT
Answer: UPDATE
UPDATE modifies existing records in a table.
8. Which SQL statement deletes records from a table?
- REMOVE
- DELETE
- ERASE
- DROP
Answer: DELETE
DELETE removes one or more records from a table.
9. Which SQL statement creates a new table?
- CREATE TABLE
- NEW TABLE
- ADD TABLE
- MAKE TABLE
Answer: CREATE TABLE
CREATE TABLE creates a new table in the database.
10. Which clause is used to filter records?
- WHERE
- FILTER
- HAVING
- SORT
Answer: WHERE
The WHERE clause filters records based on a specified condition.
11. Which SQL clause is used to sort query results?
- ORDER BY
- SORT BY
- GROUP BY
- FILTER BY
Answer: ORDER BY
ORDER BY sorts the result set in ascending or descending order.
12. Which SQL keyword removes duplicate records?
- DISTINCT
- UNIQUE
- REMOVE
- DELETE
Answer: DISTINCT
DISTINCT returns only unique values from a query.
13. Which SQL function returns the total number of rows?
- COUNT()
- SUM()
- TOTAL()
- ROWS()
Answer: COUNT()
COUNT() returns the number of rows that match a condition.
14. Which SQL function returns the highest value in a column?
- MAX()
- HIGH()
- TOP()
- LARGEST()
Answer: MAX()
MAX() returns the largest value from a column.
15. Which SQL function returns the lowest value in a column?
- MIN()
- LOW()
- SMALL()
- LEAST()
Answer: MIN()
MIN() returns the smallest value from a column.
16. Which clause groups rows with the same values?
- GROUP BY
- ORDER BY
- WHERE
- JOIN
Answer: GROUP BY
GROUP BY groups records that have the same values.
17. Which SQL statement permanently removes a table?
- DROP TABLE
- DELETE TABLE
- REMOVE TABLE
- CLEAR TABLE
Answer: DROP TABLE
DROP TABLE permanently deletes a table and its data.
18. Which key uniquely identifies each record in a table?
- Primary Key
- Foreign Key
- Unique Key
- Candidate Key
Answer: Primary Key
A Primary Key uniquely identifies every record in a table.
19. Which key creates a relationship between two tables?
- Foreign Key
- Primary Key
- Unique Key
- Index Key
Answer: Foreign Key
A Foreign Key links records between two related tables.
20. Which of the following is an advantage of MySQL?
- Open Source
- Fast Performance
- Reliable
- All of the above
Answer: All of the above
MySQL is open-source, reliable, secure, and provides excellent performance.