MariaDB is a community-developed, commercially supported fork of the MySQL relational database management system, intended to remain free and open-source software under the GNU General Public License.
MariaDB MCQs: This section contains multiple-choice questions and answers on the various topics of MariaDB. Practice these MCQs to test and enhance your skills on MariaDB.
List of MariaDB MCQs
1. MariaDB supports the fork of ____.
- MySQL RDBMS
- Oracle
- SQL Server
- SQLite
Answer: A) MySQL RDBMS
Explanation:
MariaDB supports the fork of MySQL relational database management system (RDBMS).
2. Who is the lead developer/CTO of MariaDB ____?
- Mårten Mickos
- Mark C. Burton
- Michael Widenius
- All of the above
Answer: C) Michael Widenius
Explanation:
Michael Widenius is the lead developer/CTO of MariaDB who is one of the founders of MySQL AB and the founder of Monty Program AB.
3. In MariaDB, what is Maria?
- Maria is the nickname of Widenius’
- Maria is the name of Widenius’ younger daughter
- Maria is the name of Widenius’ wife
- There is no specific reason
Answer: B) Maria is the name of Widenius’ younger daughter
Explanation:
MariaDB is named after Widenius’ younger daughter, Maria.
4. Which is faster MariaDB or MySQL?
- MariaDB is faster than MySQL
- MySQL is faster than MariaDB
- Both are the same
- None of the above
Answer: A) MariaDB is faster than MySQL
Explanation:
MariaDB is faster than MySQL based on performing queries or replication.
5. Is it possible to replace MySQL with MariaDB?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, it is possible to replace MySQL with MariaDB.
6. Which language is used to write MariaDB Server?
- BASIC
- C/C++
- B
- SQL
Answer: B) C/C++
Explanation:
MariaDB Server is written in C/C++ programming language.
7. Which command is used to create a database in MariaDB?
- CREATE DB
- CREATE ST DATABASE
- CREATE DATABASE
- CREATE NEW DATABASE
Answer: C) CREATE DATABASE
Explanation:
To create a new database in MariaDB, the CREATE DATABASE is used.
Syntax:
CREATE DATABASE Database_Name;
8. Which command is used to get the list of existing databases in MariaDB?
- USE DATABASES
- SHOW DB
- GET DATABASES
- SHOW DATABASES
Answer: D) CREATE DATABASE
Explanation:
To get the list of existing databases in MariaDB, the SHOW DATABASES is used.
Syntax:
SHOW DATABASES;
9. Which command is used to select an existing database in MariaDB?
- SELECT
- WORKON
- USE
- USE DATABASE
Answer: C) USE
Explanation:
To select an existing database in MariaDB, the USE is used.
Syntax:
USE database_name;
10. Which command is used to drop/delete an existing database in MariaDB?
- DROP DATABASES
- DROP DB
- REMOVE DATABASE
- DROP DATABASE
Answer: D) DROP DATABASE
Explanation:
To drop/delete an existing database in MariaDB, the DROP DATABASE is used.
Syntax:
DROP DATABASE database_name;
11. We can create a table by using the ____ command and get the list of all existing tables by using the ____ command in MariaDB.
- CREATE, USE
- CREATE, SHOW
- CREATE TABLE, SHOW TABLE
- CREATE TABLE, SHOW TABLES
Answer: D) CREATE TABLE, SHOW TABLES
Explanation:
We can create a table by using the CREATE TABLE command and get the list of all existing tables by using the SHOW TABLES command in MariaDB.
12. Which command is used to drop/delete an existing table in MariaDB?
- DROP TABLE
- DROP
- DELETE TABLE
- DEL TABLE
Answer: A) DROP TABLE
Explanation:
To drop/delete an existing table in MariaDB, the DROP TABLE is used.
Syntax:
DROP TABLE table_name;
13. WHERE clauses filter various statements, such as ____.
- SELECT
- UPDATE
- DELETE
- INSERT
- All of the above
Answer: E) All of the above
Explanation:
WHERE clauses filter various statements, such as SELECT, UPDATE, DELETE, and INSERT.
14. In MariaDB, the DELETE statement deletes rows from a given table and returns a ____.
- count of the total remaining rows
- count of the number of deleted rows
- unique records id of the delete row
- null value
Answer: B) count of the number of deleted rows
Explanation:
In MariaDB, the DELETE statement deletes rows from a given table and returns a count of the number of deleted rows.
15. Which MariaDB function is used to get the number of rows updated, inserted, or deleted by the preceding statement?
- COUNT()
- UPDATED_ROWS()
- ROW_COUNT()
- COUNT()
Answer: C) ROW_COUNT()
Explanation:
In MariaDB, the ROW_COUNT() function is used to get the number of rows updated, inserted, or deleted by the preceding statement.
16. Which of the following is the correct way to use ROW_COUNT() function?
- SELECT ROW_COUNT();
- ROW_COUNT();
- SELECT * ROW_COUNT();
- SHOW ROW_COUNT();
Answer: A) SELECT ROW_COUNT();
Explanation:
The correct way to use ROW_COUNT() function is:
Syntax:
SELECT ROW_COUNT();
17. Which of the following clause is used to restrict the number of returned rows?
- RESTRICT
- FIX
- LIMIT
- None of the above
Answer: C) LIMIT
Explanation:
MariaDB LIMIT clause is used to restrict the number of returned rows.
18. Which of the following query is correct to get the first two names from ‘students’ table, ordered alphabetically?
- SELECT * FROM students ASC LIMIT 2;
- SELECT * FROM students LIMIT 2;
- SELECT * FROM students ORDER BY name LIMIT 2 ASC;
- SELECT * FROM students ORDER BY name LIMIT 2;
Answer: D) SELECT * FROM students ORDER BY name LIMIT 2;
Explanation:
The correct query is to get the first two names from the ‘students’ table, ordered alphabetically
Syntax:
SELECT * FROM students ORDER BY name LIMIT 2;
19. Which statement is used to rename existing MariaDB accounts?
- RENAME
- RENAME USER
- RENAME ACCOUNT
- RENAME USERS
Answer: B) RENAME USER
Explanation:
The RENAME USER statement renames existing MariaDB accounts.
20. Which statement is used to assign a password to an existing MariaDB user account?
- PASSWORD
- USER PASSWORD
- SET PASSWORD
- SET USER PASSWORD
Answer: C) SET PASSWORD
Explanation:
The SET PASSWORD statement assigns a password to an existing MariaDB user account.
21. Which of the following is the correct query to delete a password for a user named ‘alex’?
- SET PASSWORD FOR ‘alex’@localhost = PASSWORD(“”);
- SET PASSWORD FOR ‘alex’@localhost = null;
- DEL PASSWORD FOR ‘alex’@localhost;
- SET PASSWORD FOR ‘alex’@localhost = PASSWORD(“null”);
Answer: A) SET PASSWORD FOR ‘alex’@localhost = PASSWORD(“”);
Explanation:
The correct query to delete a password for a user named ‘alex’ is:
Syntax:
SET PASSWORD FOR ‘alex’@localhost = PASSWORD(“”);
22. Which statement is used to remove one or more MariaDB roles?
- DELETE ROLE
- REVOKE ROLE
- DROP ROLES
- DROP ROLE
Answer: D) DROP ROLE
Explanation:
The DROP ROLE statement removes one or more MariaDB roles.
23. Which is not a valid string function in MariaDB?
- ASCII()
- BIN()
- HEX()
- LEFTPAD()
Answer: D) LEFTPAD()
Explanation:
The LEFTPAD() is not a valid string function in MariaDB.
24. What is the result of the following MariaDB query?
SELECT QUOTE(“Don’t!”);
- “Don\’t!”
- ‘Don\’t!’
- Don\’t!
- ‘Dont!’
Answer: B) ‘Don\’t!’
Explanation:
The result of the given query is ‘Don\’t!’
25. What will QUOTE() function return if we pass NULL in it?
- “NULL”
- ‘NULL’
- NULL
- null
Answer: C) NULL
Explanation:
The statement QUOTE(“NULL”) will return NULL. See the example below
Syntax:
SELECT QUOTE(NULL);
+————-+
| QUOTE(NULL) |
+————-+
| NULL |
+————-+
26. The TO_CHAR() function can convert ____ to a string.
- date
- datetime
- time
- timestamp
- All of the above
Answer: E) All of the above
Explanation:
The TO_CHAR() function can convert an expression of type date, datetime, time, or timestamp to a string.
27. What will be the result of the following MariaDB Query?
TO_CHAR(‘1980-01-11 04:50:39’, ‘HH24-MI-SS’)
- 16-50-39
- 04-50-39
- 1980-01-11
- 1980-01-11 04-50-39
Answer: B) 04-50-39
Explanation:
MariaDB Query “TO_CHAR(‘1980-01-11 04:50:39’, ‘HH24-MI-SS’)” will return “04-50-39”.
28. Which MariaDB operator is used for Not Equal Operation?
- <>
- !=
- Both A and B
- !
Answer: C) Both A and B
Explanation:
Both of the symbols <> and != are used for Not Equal Operations.
29. What is the name of this (<=>) Operator?
- Join Equal
- Multi Equal
- Null Check
- NULL-safe equal operator
Answer: D) NULL-safe equal operator
Explanation:
<=> is known as “NULL-safe equal operator”.
30. The output of the MariaDB Query SELECT ‘b’ BETWEEN ‘a’ AND ‘c’;?
- True
- true
- 1
- Any of the above
Answer: C) 1
Explanation:
The BETWEEN AND operator returns either 1 or 0.
31. Which are the types of joins in MariaDB?
- Left Join
- Inner Join
- Outer Join
- Right Join
- All of the above
Answer: E) All of the above
Explanation:
All of the above joins are available in MariaDB.
32. Which MariaDB operator is used to return the intersection of two or more tables?
- UNION
- INTERSECT
- INTSEC
- None of the above
Answer: B) INTERSECT
Explanation:
The INTERSECT operator is used to return the intersection of two or more tables.
33. Which MariaDB operator is used to combine the result sets of two or more SELECT statements?
- UNION
- UNION ALL
- INTERSECT
- None of the above
Answer: A) UNION
Explanation:
The UNION operator is used to combine the result sets of two or more SELECT statements.
34. Which MariaDB operator is used to combine the result sets of two or more SELECT statements without removing duplicate records?
- UNION
- UNION ALL
- INTERSECT
- None of the above
Answer: B) UNION ALL
Explanation:
The UNION ALL operator is used to combine the result sets of two or more SELECT statements without removing duplicate records.
35. Which is/are the NULL operator(s) in MariaDB?
- IS NULL
- IS NOT NULL
- ISNULL
- COALESCE
- All of the above
Answer: E) U All of the above
Explanation:
All of the above are the NULL operators for working with NULL values.
36. Which is not a large object data type in MariaDB?
- mediumblob
- tinyblob
- char(size)
- longtext
Answer: C) char(size)
Explanation:
The char(size) is not a large object data type in MariaDB. The rest of the others are used to store large object-type values.
37. Which is the correct MariaDB query to get the list of products that starts with ‘Sh’?
- SELECT product_name FROM products WHERE product_name REGEXP ‘pr__’;
- SELECT product_name FROM products WHERE product_name REGEXP ‘^pr’;
- SELECT product_name FROM products WHERE product_name REGEXP ‘*pr*’;
- SELECT product_name FROM products WHERE product_name REGEXP ‘pr’;
Answer: B) SELECT product_name FROM products WHERE product_name REGEXP ‘^pr’;
Explanation:
The correct MariaDB query to get the list of products that starts with ‘Sh’ is:
Syntax:
SELECT product_name FROM products WHERE product_name REGEXP ‘^pr’;
38. Which is the correct MariaDB query to get the list of products starting with a vowel?
- SELECT product_name FROM products WHERE product_name REGEXP ‘^[aeiou]’;
- SELECT product_name FROM products WHERE product_name REGEXP ‘^aeiou’;
- SELECT product_name FROM products WHERE product_name REGEXP ‘*[aeiou]*’;
- None of the above
Answer: A) SELECT product_name FROM products WHERE product_name REGEXP ‘^[aeiou]’;
Explanation:
The correct MariaDB query to get the list of products starting with a vowel is:
Syntax:
SELECT product_name FROM products WHERE product_name REGEXP ‘^[aeiou]’;
39. What is the correct query syntax to delete an index in MariaDB?
- DROP index_name;
- DROP index_name FROM table_name;
- DROP INDEX index_name FROM table_name;
- DROP INDEX index_name ON table_name;
Answer: D) DROP INDEX index_name ON table_name;
Explanation:
The correct query syntax to delete an index in MariaDB is:
Syntax:
DROP INDEX index_name ON table_name;
40. Which MariaDB statement is used to display the list of all indexes?
- SHOW INDEX
- DISPLAY INDEX
- SELECT * INDEX
- DESC INDEX
Answer: A) SHOW INDEX
Explanation:
To get the list of all existing indexes associated with a table, we use the SHOW INDEX command.
Syntax:
SHOW INDEX FROM table_name\G
41. The ____ keyword within a CREATE TABLE statement spawns a temporary table.
- TEMP
- TEMPORARY TABLE
- TEMPORARY
- None of the above
Answer: C) TEMPORARY
Explanation:
The TEMPORARY keyword within a CREATE TABLE statement spawns a temporary table.
42. In MariaDB, the ____ attribute is used for generating a unique identity automatically for new rows.
- AI
- AUTO
- AUTO_INCR
- AUTO_INCREMENT
Answer: D) AUTO_INCREMENT
Explanation:
In MariaDB, the AUTO_INCREMENT attribute is used for generating a unique identity automatically for new rows.
43. Which is the correct MariaDB query for finding the maximum value and grouping the results?
- SELECT std_name, MAX(score) FROM students;
- SELECT std_name, MAX(score) FROM students GROUP BY std_name;
- SELECT std_name, MAX(score) FROM students ORDER BY std_name;
- SELECT std_name, MAX(score) FROM students GROUP BY std_name ASC;
Answer: B) SELECT std_name, MAX(score) FROM students GROUP BY std_name;
Explanation:
The correct MariaDB query for finding the maximum value and grouping the results:
Syntax:
SELECT std_name, MAX(score) FROM students GROUP BY std_name;
44. Which is the correct MariaDB query syntax to declare a variable having the type of a column from the table?
- DECLARE variable_name TYPE OF table_name.column_name;
- DECLARE variable_name IN table_name.column_name;
- DECLARE variable_name TYPE OF table_name.column_name FROM table_name;
- None of the above
Answer: A) DECLARE variable_name TYPE OF table_name.column_name;
Explanation:
The correct MariaDB query syntax to declare a variable having the type of a column from the table is:
Syntax:
DECLARE variable_name TYPE OF table_name.column_name;
45. During the variable declaration which keyword is used to get the row data type from the table?
- TYPE OF
- ROW TYPE
- ROW TYPE OF
- All of the above
Answer: C) ROW TYPE OF
Explanation:
The ROW TYPE OF keyword is used to get the row data type from the table.
46. In MariaDB, a user-defined variable name must be preceded by ____.
- #
- $
- ^
- @
Answer: D) @
Explanation:
In MariaDB, a user-defined variable name must be preceded by a single at (@).
47. Which function can be used to calculate the age in MariaDB?
- TIMESTAMP()
- TIMESTAMPS()
- TIMESTAMPDIFF()
- TIMESTAMPDIF()
Answer: C) TIMESTAMPDIFF()
Explanation:
The TIMESTAMPDIFF() function can be used to calculate the age in MariaDB.
48. Which is the correct MariaDB query to lock an existing user?
- CREATE USER ‘alex’@’localhost’ ACCOUNT LOCK;
- ALTER USER ‘alex’@’localhost’ ACCOUNT LOCK;
- ALTER USER ‘alex’@’localhost’ LOCK;
- ALTER USER LOCK ‘alex’@’localhost’;
Answer: B) ALTER USER ‘alex’@’localhost’ ACCOUNT LOCK;
Explanation:
The correct MariaDB query to lock an existing user is:
Syntax:
ALTER USER ‘alex’@’localhost’ ACCOUNT LOCK;
49. Which is the correct MariaDB query for removing a default role from the current user?
- SET DEFAULT ROLE NONE;
- SET DEFAULT ROLE NULL;
- SET DEFAULT ROLE EMPTY;
- SET DEFAULT ROLE REMOVE;
Answer: A) SET DEFAULT ROLE NONE;
Explanation:
The correct MariaDB query for removing a default role from the current user is:
Syntax:
SET DEFAULT ROLE NONE;
50. Which is the correct MariaDB query for removing a default role for another user (‘alex’)?
- SET DEFAULT ROLE NONE FOR alex;
- SET DEFAULT ROLE NULL FOR alex;
- SET DEFAULT ROLE EMPTY FOR alex;
- SET DEFAULT ROLE REMOVE FOR alex;
Answer: A) SET DEFAULT ROLE NONE FOR alex;
Explanation:
The correct MariaDB query for removing a default role for another user (‘alex’) is: