Learn MYSQL MCQs

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

What MySQL function is used to return the number of characters in a string?

1) LENGTH()

2) STRLEN()

3) SIZE()

4) CHAR_COUNT()

Answer : Option 1

Which MySQL data type is used to store a large amount of text?

1) VARCHAR

2) STRING

3) TEXT

4) CHAR

Answer : Option 3

How can you retrieve all columns from a table in MySQL?

1) SHOW COLUMNS FROM table_name;

2) DESCRIBE table_name;

3) SELECT ALL COLUMNS FROM table_name;

4) SELECT * FROM table_name;

Answer : Option 4

What is the MySQL command to create a new user?

1) INSERT USER 'username'@'host' PASSWORD 'password';

2) NEW USER 'username'@'host' SET PASSWORD 'password';

3) ADD USER 'username'@'host' WITH PASSWORD 'password';

4) CREATE USER 'username'@'host' IDENTIFIED BY 'password';

Answer : Option 4

Which MySQL command is used to modify an existing record in a table?

1) UPDATE

2) CHANGE

3) ALTER

4) MODIFY

Answer : Option 1

Which clause is used to filter the results of a SELECT query in MySQL?

1) HAVING

2) LIMIT

3) FILTER

4) WHERE

Answer : Option 4

What is the purpose of the PRIMARY KEY constraint in MySQL?

1) To enforce data integrity in a column

2) To define a relationship between tables

3) To uniquely identify each record in a table

4) To index columns for faster retrieval

Answer : Option 3

What is the MySQL command to list all databases on the server?

1) LIST DATABASES;

2) EXAMINE DATABASES;

3) SHOW DATABASES;

4) DISPLAY DATABASES;

Answer : Option 3

What does the MySQL function COALESCE() do?

1) Combines multiple rows into a single row

2) Counts the number of NULL values in a column

3) Returns the first non-NULL value in a list

4) Checks if a column is NULL

Answer : Option 3

Which of the following MySQL clauses is used to sort the result set?

1) SORT BY

2) GROUP BY

3) ORDER BY

4) ARRANGE BY

Answer : Option 3