mysql banner

MySQL Multiple Choice Questions (MCQs) and Answers

Master MySQL with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of MySQL concepts. Begin your placement preparation journey now!

Q31

Q31 What does the UPDATE statement do in SQL?

A

Deletes records

B

Modifies existing records

C

Inserts new records

D

Creates a table

Q32

Q32 What is the purpose of the DELETE statement in SQL?

A

To drop a table

B

To remove specific rows from a table

C

To modify rows

D

To create a new table

Q33

Q33 Which clause should be used with the DELETE statement to specify which rows to remove?

A

WHERE

B

HAVING

C

GROUP BY

D

ORDER BY

Q34

Q34 What does the SQL clause 'ON DUPLICATE KEY UPDATE' do in an INSERT statement?

A

Inserts a new row as a duplicate

B

Updates the row if it already exists

C

Deletes the duplicate row

D

None of the above

Q35

Q35 What is the result of the following SQL query?
SELECT COUNT(*) FROM Users;

A

The number of rows in Users

B

The list of users

C

The first user in the table

D

Total data size of Users

Q36

Q36 Consider the following SQL command:
INSERT INTO Customers (Name, Age) VALUES ('Alice', 30);
What does this command do?

A

Inserts a new row into Customers

B

Updates a row in Customers

C

Deletes a row from Customers

D

None of the above

Q37

Q37 What does the following SQL statement do?
UPDATE Users SET Age = Age + 1 WHERE ID = 1;

A

Increments age of all users

B

Sets all users' age to 1

C

Increments age of the user with ID 1

D

Deletes user with ID 1

Q38

Q38 How does the SQL statement INSERT INTO Orders (ProductID, Quantity) VALUES (101, 1) ON DUPLICATE KEY UPDATE Quantity = Quantity + 1; function?

A

Adds a new order or increases quantity if exists

B

Creates multiple entries for same product

C

Deletes previous entries for product

D

None of the above

Q39

Q39 Identify the mistake in this SQL statement:
UPDATE User SET Status = 'Active' WHER ID = 5;

A

Typo in WHERE clause

B

Incorrect column name

C

Both

D

None of the above

Q40

Q40 What is wrong with this SQL command:
DELETE FROM Products WHERE;

A

Incomplete WHERE clause

B

Syntax is correct

C

Unnecessary semicolon

D

Extra space in statement

Q41

Q41 What is the main purpose of using a JOIN in SQL?

A

To delete records from a table

B

To merge rows from two or more tables

C

To update records in a table

D

To create a new table

Q42

Q42 Which type of JOIN returns only the rows that have a match in both joined tables?

A

LEFT JOIN

B

RIGHT JOIN

C

INNER JOIN

D

FULL JOIN

Q43

Q43 What does a FULL OUTER JOIN do?

A

Combines all rows from both tables where matches exist, filling with NULLs where there is no match

B

Only combines matching rows

C

Only returns non-matching rows of both tables

D

None of the above

Q44

Q44 Which SQL keyword is used to create a subquery?

A

SUB

B

WITH

C

SELECT

D

IN

Q45

Q45 In SQL, a subquery can be placed in which of the following clauses?

A

WHERE

B

FROM

C

SELECT

D

All of the above

Q46

Q46 Which type of subquery is executed once for each row processed by the parent query?

A

Correlated

B

Non-correlated

C

Repeated

D

Static

Q47

Q47 What does the following SQL statement accomplish?
SELECT * FROM Employees JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID;

A

Retrieves all employees and their department data

B

Updates employee records

C

Deletes departments

D

Creates new departments

Q48

Q48 Consider this SQL statement:
SELECT Name, Product FROM Customers LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID WHERE Orders.OrderID IS NULL; What does this query return?

A

Names and products of customers who have not placed any orders

B

All customer and order pairs

C

All customers and their orders

D

Invalid query

Q49

Q49 What does this SQL query achieve?
SELECT EmployeeID, MAX(Salary) FROM Employees GROUP BY DepartmentID HAVING COUNT(EmployeeID) > 1;

A

Retrieves the highest salary in each department with more than one employee

B

Lists all employees' salaries

C

Deletes entries with max salaries

D

None of the above

Q50

Q50 Identify the error in this SQL statement:
SELECT * FROM Orders INNER JOIN Customers ON Orders.CustID = Customers.ID WHERE Customers.Status = 'Active';

A

There is no error

B

Misuse of JOIN

C

Syntax error in the WHERE clause

D

Column name mismatch in the ON clause

Q51

Q51 What is incorrect in the following SQL command?
SELECT FROM Employees, Departments WHERE Employees.DepartmentID = Department.ID;

A

SELECT clause is incomplete

B

WHERE clause is incorrect

C

Syntax is correct

D

Using WHERE instead of ON

Q52

Q52 What is the primary purpose of an index in a database?

A

To increase database size

B

To enhance data security

C

To speed up data retrieval

D

To transform data

Q53

Q53 What type of index would be most effective for a column that stores unique values in MySQL?

A

Primary index

B

Secondary index

C

Clustered index

D

Non-clustered index

Q54

Q54 Which MySQL engine supports FULLTEXT indexing?

A

MyISAM

B

InnoDB

C

Both

D

Neither

Q55

Q55 When is a composite index useful in MySQL?

A

When querying multiple columns frequently

B

Only with the PRIMARY KEY

C

For single-column searches

D

Never

Q56

Q56 What does the following SQL command do?
CREATE INDEX idx_name ON Customers (Name);

A

Creates a unique constraint on Name

B

Deletes an index on Name

C

Creates an index on the Name column

D

Alters the Name column

Q57

Q57 How does the query optimizer use indexes in MySQL?

A

To decide the best order to join tables

B

To reduce the use of disk space

C

To increase transaction speed

D

To automatically update table statistics

Q58

Q58 What is the effect of adding an index to a table on the performance of INSERT statements?

A

Slows down INSERTs

B

Speeds up INSERTs

C

No effect on INSERTs

D

INSERTs become unpredictable

Q59

Q59 Identify the error in this SQL statement:
CREATE INDEX ON Orders (OrderDate);

A

Missing index name

B

Syntax is correct

C

Should be a UNIQUE index

D

No column specified

Q60

Q60 What is wrong with this SQL command:
CREATE INDEX idx_product_id ON Products (ProductID) WHERE ProductID IS NULL;

A

MySQL does not support filtered indexes

B

Index name is incorrect

C

Syntax error in WHERE clause

D

All are correct

ad verticalad vertical
ad