Learn MYSQL MCQs
Prepare MYSQL MCQs (Multiple choice Questions) for exam and job interviews.
Which command is used to change the default database in MySQL?
1) USE database_name;
2) SET DATABASE database_name;
3) CHANGE DATABASE database_name;
4) SWITCH DATABASE database_name;
Answer : Option 1
What does the IFNULL function do?
1) Returns a specified value if the expression is NULL
2) Replaces NULL values with zeros
3) Checks if a column is NULL
4) Removes NULL values from a table
Answer : Option 1
Which function is used to round a number to a specified number of decimal places?
1) ROUND(number, decimals)
2) TRUNCATE(number, decimals)
3) CEIL(number)
4) FLOOR(number)
Answer : Option 1
What is the function of the LEFT JOIN clause?
1) Returns all records from the left table and matching records from the right table
2) Returns all records from the right table and matching records from the left table
3) Returns only matching records from both tables
4) Returns all records from both tables
Answer : Option 1
Which command is used to check for syntax errors in a MySQL query without executing it?
1) EXPLAIN query;
2) CHECK query;
3) VALIDATE query;
4) VERIFY query;
Answer : Option 1
What is the function of the FOREIGN KEY constraint?
1) To enforce referential integrity between tables
2) To ensure a column contains unique values
3) To enforce a non-null constraint
4) To automatically generate a unique identifier
Answer : Option 1
What command is used to remove a table from the database?
1) DESTROY TABLE
2) DELETE TABLE
3) REMOVE TABLE
4) DROP TABLE
Answer : Option 4
Which of the following is used to define a new primary key in MySQL?
1) NEW PRIMARY KEY column_name
2) SET PRIMARY KEY column_name
3) PRIMARY KEY (column_name)
4) DEFINE PRIMARY KEY column_name
Answer : Option 3
What MySQL clause is used to limit the number of rows returned?
1) ROWNUM
2) COUNT
3) LIMIT
4) TOP
Answer : Option 3
Which statement is used to remove a stored procedure in MySQL?
1) DELETE PROCEDURE procedure_name;
2) TRUNCATE PROCEDURE procedure_name;
3) DROP PROCEDURE procedure_name;
4) REMOVE PROCEDURE procedure_name;
Answer : Option 3