Learn MYSQL MCQs

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

How do you rename a table in MySQL?

1) ALTER TABLE old_name RENAME TO new_name;

2) CHANGE TABLE old_name TO new_name;

3) RENAME TABLE old_name TO new_name;

4) MODIFY TABLE old_name TO new_name;

Answer : Option 3

What is the correct command to grant privileges to a user in MySQL?

1) ASSIGN PRIVILEGES TO user@host;

2) GRANT SELECT, INSERT ON database.table TO user@host;

3) GIVE PRIVILEGES TO user@host;

4) PROVIDE ACCESS TO user@host;

Answer : Option 2

Which SQL statement is used to extract data from a database?

1) PULL

2) RETRIEVE

3) EXTRACT

4) SELECT

Answer : Option 4

What does the COUNT(*) function do in MySQL?

1) Counts the number of columns in a table

2) Counts the number of unique values in a column

3) Counts the number of rows in a table

4) Counts the number of NULL values in a column

Answer : Option 3

What is the purpose of the GROUP BY clause in MySQL?

1) To filter data by a specific condition

2) To limit the number of rows returned

3) To arrange data in descending order

4) To group rows that have the same values in specified columns

Answer : Option 4

Which MySQL function is used to get the current date?

1) SYSDATE()

2) CURRENT_DATE()

3) CURDATE()

4) NOW()

Answer : Option 3

What is the default port for MySQL?

1) 3309

2) 3307

3) 3308

4) 3306

Answer : Option 4

Which of the following is used to retrieve unique values in MySQL?

1) FILTER

2) UNIQUE

3) DIFFERENT

4) DISTINCT

Answer : Option 4

How can you delete a column from an existing MySQL table?

1) DROP COLUMN column_name FROM table_name;

2) DELETE COLUMN column_name FROM table_name;

3) REMOVE COLUMN column_name FROM table_name;

4) ALTER TABLE table_name DROP COLUMN column_name;

Answer : Option 4

What does the SQL keyword NULL mean?

1) A non-numeric value

2) Zero

3) A missing or undefined value

4) An empty string

Answer : Option 3