Learn MYSQL MCQs

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

Which SQL statement is used to update existing records in a table?

1) UPDATE table_name SET column1 = value1;

2) MODIFY table_name SET column1 = value1;

3) CHANGE table_name SET column1 = value1;

4) ALTER table_name SET column1 = value1;

Answer : Option 1

What is the purpose of the SQL HAVING clause?

1) Filters records after grouping

2) Filters records before grouping

3) Sorts the records

4) Joins two tables

Answer : Option 1

How do you select all columns from a table in MySQL?

1) SELECT * FROM table_name;

2) SELECT ALL FROM table_name;

3) SELECT COLUMNS FROM table_name;

4) SELECT EVERY COLUMN FROM table_name;

Answer : Option 1

Which SQL function is used to find the maximum value in a column?

1) MAX()

2) TOP()

3) HIGHEST()

4) GREATEST()

Answer : Option 1

What does the SQL UNION operator do?

1) Combines the results of two or more SELECT statements

2) Joins two tables

3) Filters records

4) Sorts results

Answer : Option 1

How can you add a foreign key constraint in MySQL?

1) ALTER TABLE table_name ADD FOREIGN KEY (column_name) REFERENCES other_table(column_name);

2) ADD FOREIGN KEY (column_name) TO table_name;

3) CREATE FOREIGN KEY (column_name) ON table_name;

4) LINK column_name TO other_table(column_name);

Answer : Option 1

Which command is used to show all databases in MySQL?

1) SHOW DATABASES;

2) LIST DATABASES;

3) SHOW ALL DATABASES;

4) DISPLAY DATABASES;

Answer : Option 1

What is the SQL command to show the current user?

1) SELECT CURRENT_USER();

2) SHOW USER();

3) SELECT USER();

4) GET USER();

Answer : Option 1

How do you remove all records from a table without deleting the table itself?

1) TRUNCATE TABLE table_name;

2) DELETE ALL FROM table_name;

3) DROP TABLE table_name;

4) REMOVE ALL FROM table_name;

Answer : Option 1

Which SQL keyword is used to prevent duplicate records?

1) DISTINCT

2) UNIQUE

3) NO_DUPLICATES

4) DIFFERENT

Answer : Option 1