Learn MYSQL MCQs

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

Which command is used to view the current user in MySQL?

1) CURRENT_USER()

2) SHOW USER;

3) GET USER;

4) SELECT USER();

Answer : Option 4

What does the SQL keyword DISTINCT do?

1) Removes duplicates from the result set

2) Groups the result set

3) Sorts the result set

4) Limits the result set

Answer : Option 1

What MySQL command is used to copy a table?

1) COPY TABLE table_name TO new_table_name;

2) CREATE TABLE new_table_name AS SELECT * FROM table_name;

3) CLONE TABLE table_name TO new_table_name;

4) DUPLICATE TABLE table_name AS new_table_name;

Answer : Option 2

Which statement is used to define a foreign key in MySQL?

1) FOREIGN KEY (column_name) REFERENCES other_table(column_name);

2) ADD FOREIGN KEY (column_name) TO table_name;

3) SET FOREIGN KEY (column_name);

4) CREATE FOREIGN KEY (column_name) IN table_name;

Answer : Option 1

How do you delete a column from a MySQL table?

1) DROP COLUMN column_name FROM table_name;

2) ALTER TABLE table_name DROP COLUMN column_name;

3) DELETE COLUMN column_name FROM table_name;

4) REMOVE COLUMN column_name FROM table_name;

Answer : Option 2

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

1) To round a number to the nearest integer

2) To round a number to a specified number of decimal places

3) To convert a number to an integer

4) To find the average of a set of numbers

Answer : Option 2

Which MySQL data type is used for storing binary data?

1) BLOB

2) BINARY

3) VARBINARY

4) TEXT

Answer : Option 1

What is the MySQL command to add a new column to an existing table?

1) ALTER TABLE table_name ADD column_name data_type;

2) MODIFY TABLE table_name ADD column_name data_type;

3) NEW TABLE table_name ADD column_name data_type;

4) CREATE COLUMN column_name IN table_name;

Answer : Option 1

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

1) GET

2) SELECT

3) FETCH

4) RETRIEVE

Answer : Option 2

How do you prevent SQL injection in MySQL?

1) Use prepared statements

2) Escape special characters

3) Use stored procedures

4) Validate user input

Answer : Option 1