Learn MYSQL MCQs

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

Which SQL command is used to back up a MySQL database?

1) BACKUP DATABASE database_name;

2) mysqldump database_name;

3) EXPORT DATABASE database_name;

4) SAVE DATABASE database_name;

Answer : Option 2

What is the purpose of the SQL DISTINCT keyword?

1) To return unique values

2) To sort values

3) To limit results

4) To group values

Answer : Option 1

How do you create a trigger in MySQL?

1) CREATE TRIGGER trigger_name;

2) ADD TRIGGER trigger_name;

3) DEFINE TRIGGER trigger_name;

4) NEW TRIGGER trigger_name;

Answer : Option 1

Which function is used to find the total number of characters in a string?

1) LEN()

2) COUNT()

3) LENGTH()

4) CHAR_LENGTH()

Answer : Option 3

What is a foreign key in MySQL?

1) A key used to link two tables together

2) A key that uniquely identifies a record

3) A key that cannot be NULL

4) A primary key of another table

Answer : Option 1

How do you change the data type of an existing column in MySQL?

1) ALTER TABLE table_name MODIFY column_name new_data_type;

2) ALTER TABLE table_name CHANGE column_name new_data_type;

3) CHANGE COLUMN column_name TO new_data_type;

4) MODIFY TABLE table_name CHANGE column_name new_data_type;

Answer : Option 1

Which command is used to remove a column from a MySQL table?

1) ALTER TABLE table_name DROP COLUMN column_name;

2) REMOVE COLUMN column_name FROM table_name;

3) DELETE COLUMN column_name FROM table_name;

4) CLEAR COLUMN column_name IN table_name;

Answer : Option 1

What is the maximum length of a VARCHAR column in MySQL?

1) 255 characters

2) 65,535 characters

3) 16,383 characters

4) 1,000 characters

Answer : Option 2

Which command is used to import data from a file into a MySQL table?

1) LOAD DATA INFILE

2) IMPORT FILE

3) INSERT FROM FILE

4) UPLOAD FILE

Answer : Option 1

How do you create an index on a column in MySQL?

1) CREATE INDEX index_name ON table_name (column_name);

2) ADD INDEX index_name TO table_name (column_name);

3) SET INDEX index_name FOR table_name (column_name);

4) DEFINE INDEX index_name IN table_name (column_name);

Answer : Option 1