Learn MYSQL MCQs

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

What is the purpose of the MySQL function IFNULL()?

1) Replaces NULL with a default value

2) Returns NULL if the expression is not NULL

3) Returns a specified value if the expression is NULL

4) Checks if a value is NULL

Answer : Option 3

Which MySQL function is used to round a number to a specific number of decimal places?

1) ROUND()

2) FLOOR()

3) TRUNC()

4) CEIL()

Answer : Option 1

What is the purpose of the MySQL function NOW()?

1) Returns the current date and time

2) Returns the current time only

3) Returns the current timestamp

4) Returns the current date only

Answer : Option 1

How do you delete all data from a table in MySQL without removing the table itself?

1) TRUNCATE TABLE table_name;

2) CLEAR TABLE table_name;

3) DROP TABLE table_name;

4) DELETE TABLE table_name;

Answer : Option 1

Which MySQL function can be used to generate a random number?

1) RAND()

2) UUID()

3) RANDOM()

4) NEWID()

Answer : Option 1

What is the purpose of the MySQL command SET?

1) To assign values to variables

2) To insert data into a table

3) To create a new table

4) To change the structure of a table

Answer : Option 1

How do you remove duplicate rows in a SELECT statement?

1) Using the FILTER keyword

2) Using the CLEAN keyword

3) Using the DISTINCT keyword

4) Using the UNIQUE keyword

Answer : Option 3

What is the purpose of the MySQL function DATE_FORMAT()?

1) Formats a date as specified

2) Changes the date format of the server

3) Converts a string to a date

4) Returns the current date and time

Answer : Option 1

Which MySQL command is used to repair a table?

1) REPAIR TABLE table_name;

2) FIX TABLE table_name;

3) CORRECT TABLE table_name;

4) RESTORE TABLE table_name;

Answer : Option 1

Which MySQL function returns the position of the first occurrence of a substring?

1) POSITION()

2) LOCATE()

3) INSTR()

4) FIND()

Answer : Option 2