Learn MYSQL MCQs
Prepare MYSQL MCQs (Multiple choice Questions) for exam and job interviews.
What does the SQL SUBSTRING_INDEX() function do?
1) Returns a substring from a string before a specified delimiter
2) Finds the index of a substring
3) Extracts a substring from a string
4) Returns the last character of a string
Answer : Option 1
How do you perform a cross join in MySQL?
1) SELECT * FROM table1 CROSS JOIN table2;
2) SELECT * FROM table1, table2;
3) JOIN table1 AND table2;
4) SELECT * FROM table1 INNER JOIN table2;
Answer : Option 1
Which command is used to flush the privileges in MySQL?
1) FLUSH PRIVILEGES;
2) RESET PRIVILEGES;
3) CLEAR PRIVILEGES;
4) REFRESH PRIVILEGES;
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) ALTER TABLE table_name ADD INDEX index_name (column_name);
3) INDEX table_name (column_name);
4) SET INDEX index_name ON table_name (column_name);
Answer : Option 1
What does the SQL FIND_IN_SET() function do?
1) Finds the position of a value in a comma-separated list
2) Counts the number of elements in a set
3) Calculates the sum of a set
4) Finds the maximum value in a set
Answer : Option 1
How do you create a backup of a table?
1) CREATE TABLE new_table AS SELECT * FROM old_table;
2) COPY old_table TO new_table;
3) EXPORT old_table TO new_table;
4) BACKUP TABLE old_table TO new_table;
Answer : Option 1
Which SQL statement is used to modify an existing table?
1) ALTER TABLE table_name;
2) CHANGE TABLE table_name;
3) UPDATE TABLE table_name;
4) MODIFY TABLE table_name;
Answer : Option 1
What is the purpose of the SQL EXISTS operator?
1) Tests for the existence of any record in a subquery
2) Counts the number of records
3) Returns true if a condition is met
4) Checks if a value exists in a list
Answer : Option 1
How do you change the character set of a database in MySQL?
1) ALTER DATABASE database_name CHARACTER SET utf8;
2) SET CHARACTER SET database_name TO utf8;
3) CHANGE DATABASE database_name CHARACTER SET utf8;
4) MODIFY DATABASE database_name TO CHARACTER SET utf8;
Answer : Option 1
Which function is used to calculate the sum of a column in MySQL?
1) SUM()
2) TOTAL()
3) COUNT()
4) ADD()
Answer : Option 1