Learn MYSQL MCQs

Prepare MYSQL MCQs (Multiple choice Questions) for exam and job interviews.

Which command is used to backup a MySQL database?

1) mysqldump

2) BACKUP DATABASE

3) SAVE DATABASE

4) EXPORT DATABASE

Answer : Option 1

What does the SQL command TRUNCATE do?

1) Removes all rows from a table without logging individual row deletions

2) Deletes the table structure

3) Removes specific rows based on condition

4) Clears the structure of a table

Answer : Option 1

What is the default character set for MySQL?

1) latin1

2) utf8

3) ascii

4) utf8mb4

Answer : Option 1

How do you define a unique constraint on a column?

1) ALTER TABLE table_name ADD UNIQUE (column_name);

2) SET UNIQUE (column_name) IN table_name;

3) MODIFY TABLE table_name ADD UNIQUE COLUMN (column_name);

4) CREATE UNIQUE (column_name) IN table_name;

Answer : Option 1

What does the SQL command SHOW COLUMNS do?

1) Displays information about columns in a table

2) Shows data in a table

3) Displays all tables in a database

4) Shows indexes in a table

Answer : Option 1

How can you get the last inserted ID in MySQL?

1) SELECT LAST_INSERT_ID();

2) GET LAST_ID();

3) FETCH LAST_ID();

4) RETURN LAST_INSERT_ID();

Answer : Option 1

What SQL command is used to create a temporary table?

1) CREATE TEMPORARY TABLE table_name;

2) NEW TEMPORARY TABLE table_name;

3) CREATE TABLE TEMP table_name;

4) DEFINE TEMPORARY TABLE table_name;

Answer : Option 1

Which MySQL function is used to retrieve the number of rows affected by the last statement?

1) ROW_COUNT()

2) COUNT_ROWS()

3) AFFECTED_ROWS()

4) LAST_ROWS()

Answer : Option 1

Which SQL command is used to remove a table from a database?

1) DELETE TABLE table_name;

2) DROP TABLE table_name;

3) REMOVE TABLE table_name;

4) CLEAR TABLE table_name;

Answer : Option 2

What is the purpose of the SQL COUNT() function?

1) To count the number of rows in a query

2) To sum the values in a column

3) To find the average value

4) To get the maximum value

Answer : Option 1