Learn MYSQL MCQs

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

How do you retrieve a specific number of records in MySQL?

1) SELECT * FROM table_name LIMIT number;

2) SELECT TOP number FROM table_name;

3) SELECT FIRST number FROM table_name;

4) SELECT number ROWS FROM table_name;

Answer : Option 1

What is the purpose of the SQL FORMAT() function?

1) Formats a number or date

2) Counts records

3) Concatenates strings

4) Finds the average value

Answer : Option 1

Which SQL statement is used to create a new user in MySQL?

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

2) ADD USER 'username'@'host' 'password';

3) NEW USER 'username'@'host' 'password';

4) REGISTER USER 'username'@'host' 'password';

Answer : Option 1

What does the SQL CONVERT() function do?

1) Converts a value from one data type to another

2) Formats a string

3) Counts characters

4) Extracts substrings

Answer : Option 1

How do you change the default character set of a table?

1) ALTER TABLE table_name CONVERT TO CHARACTER SET utf8;

2) SET CHARACTER SET FOR table_name TO utf8;

3) CHANGE CHARACTER SET FOR table_name TO utf8;

4) MODIFY CHARACTER SET FOR table_name TO utf8;

Answer : Option 1

Which SQL command is used to create an index on a table?

1) CREATE INDEX index_name ON table_name (column_name);

2) ADD INDEX index_name ON table_name (column_name);

3) SET INDEX index_name FOR table_name (column_name);

4) INDEX table_name (column_name);

Answer : Option 1

What does the SQL TRUNCATE command do?

1) Removes all records from a table quickly

2) Deletes a specific record from a table

3) Removes the table structure

4) Drops the database

Answer : Option 1

How do you fetch unique records from a table?

1) SELECT DISTINCT column_name FROM table_name;

2) SELECT UNIQUE column_name FROM table_name;

3) SELECT NO_DUPLICATES column_name FROM table_name;

4) SELECT DIFFERENT column_name FROM table_name;

Answer : Option 1

Which function is used to count the number of rows that match a specified criterion?

1) COUNT()

2) SUM()

3) TOTAL()

4) NUMBER()

Answer : Option 1

How do you execute a stored procedure in MySQL?

1) CALL procedure_name();

2) EXEC procedure_name();

3) RUN procedure_name();

4) INVOKE procedure_name();

Answer : Option 1