Learn MYSQL MCQs

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

How do you create a new database in MySQL?

1) CREATE DATABASE database_name;

2) NEW DATABASE database_name;

3) ADD DATABASE database_name;

4) DEFINE DATABASE database_name;

Answer : Option 1

What does the SQL LIMIT clause do?

1) Limits the number of rows returned

2) Filters records

3) Sorts records

4) Groups records

Answer : Option 1

How do you retrieve the last inserted ID in MySQL?

1) SELECT LAST_INSERT_ID();

2) SELECT MAX(id) FROM table_name;

3) SELECT GET_LAST_ID();

4) SELECT LAST_ID();

Answer : Option 1

Which command is used to import a CSV file into MySQL?

1) LOAD DATA INFILE 'file.csv' INTO TABLE table_name;

2) IMPORT DATA FROM 'file.csv' INTO TABLE table_name;

3) UPLOAD 'file.csv' TO table_name;

4) INSERT FROM 'file.csv' INTO table_name;

Answer : Option 1

How can you create a temporary table in MySQL?

1) CREATE TEMPORARY TABLE temp_table_name;

2) CREATE TABLE temp_table_name TEMP;

3) NEW TEMPORARY TABLE temp_table_name;

4) CREATE TABLE temp_table_name WITH TEMP;

Answer : Option 1

Which SQL function is used to count the number of rows?

1) COUNT()

2) SUM()

3) TOTAL()

4) NUMBER()

Answer : Option 1

What does the SQL CONCAT_WS() function do?

1) Concatenates strings with a separator

2) Finds the length of a string

3) Extracts substrings

4) Counts characters

Answer : Option 1

How do you add an auto-increment attribute to a column?

1) CREATE TABLE table_name (column_name INT AUTO_INCREMENT);

2) ALTER TABLE table_name ADD column_name INT AUTO_INCREMENT;

3) MODIFY TABLE table_name column_name INT AUTO_INCREMENT;

4) ADD column_name INT AUTO_INCREMENT TO table_name;

Answer : Option 1

What does the SQL GROUP_CONCAT() function do?

1) Concatenates values from multiple rows into a single string

2) Counts the number of unique values

3) Calculates the average of a column

4) Finds the maximum value

Answer : Option 1

Which command is used to display the structure of a table?

1) DESCRIBE table_name;

2) SHOW COLUMNS FROM table_name;

3) SHOW TABLE STRUCTURE table_name;

4) VIEW table_name;

Answer : Option 1