Q31
Q31 What does the UPDATE statement do in SQL?
Deletes records
Modifies existing records
Inserts new records
Creates a table
Q32
Q32 What is the purpose of the DELETE statement in SQL?
To drop a table
To remove specific rows from a table
To modify rows
To create a new table
Q33
Q33 Which clause should be used with the DELETE statement to specify which rows to remove?
WHERE
HAVING
GROUP BY
ORDER BY
Q34
Q34 What does the SQL clause 'ON DUPLICATE KEY UPDATE' do in an INSERT statement?
Inserts a new row as a duplicate
Updates the row if it already exists
Deletes the duplicate row
None of the above
Q35
Q35 What is the result of the following SQL query?
SELECT COUNT(*) FROM Users;
The number of rows in Users
The list of users
The first user in the table
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?
Inserts a new row into Customers
Updates a row in Customers
Deletes a row from Customers
None of the above
Q37
Q37 What does the following SQL statement do?
UPDATE Users SET Age = Age + 1 WHERE ID = 1;
Increments age of all users
Sets all users' age to 1
Increments age of the user with ID 1
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?
Adds a new order or increases quantity if exists
Creates multiple entries for same product
Deletes previous entries for product
None of the above
Q39
Q39 Identify the mistake in this SQL statement:
UPDATE User SET Status = 'Active' WHER ID = 5;
Typo in WHERE clause
Incorrect column name
Both
None of the above
Q40
Q40 What is wrong with this SQL command:
DELETE FROM Products WHERE;
Incomplete WHERE clause
Syntax is correct
Unnecessary semicolon
Extra space in statement
Q41
Q41 What is the main purpose of using a JOIN in SQL?
To delete records from a table
To merge rows from two or more tables
To update records in a table
To create a new table
Q42
Q42 Which type of JOIN returns only the rows that have a match in both joined tables?
LEFT JOIN
RIGHT JOIN
INNER JOIN
FULL JOIN
Q43
Q43 What does a FULL OUTER JOIN do?
Combines all rows from both tables where matches exist, filling with NULLs where there is no match
Only combines matching rows
Only returns non-matching rows of both tables
None of the above
Q44
Q44 Which SQL keyword is used to create a subquery?
SUB
WITH
SELECT
IN
Q45
Q45 In SQL, a subquery can be placed in which of the following clauses?
WHERE
FROM
SELECT
All of the above
Q46
Q46 Which type of subquery is executed once for each row processed by the parent query?
Correlated
Non-correlated
Repeated
Static
Q47
Q47 What does the following SQL statement accomplish?
SELECT * FROM Employees JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID;
Retrieves all employees and their department data
Updates employee records
Deletes departments
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?
Names and products of customers who have not placed any orders
All customer and order pairs
All customers and their orders
Invalid query
Q49
Q49 What does this SQL query achieve?
SELECT EmployeeID, MAX(Salary) FROM Employees GROUP BY DepartmentID HAVING COUNT(EmployeeID) > 1;
Retrieves the highest salary in each department with more than one employee
Lists all employees' salaries
Deletes entries with max salaries
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';
There is no error
Misuse of JOIN
Syntax error in the WHERE clause
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;
SELECT clause is incomplete
WHERE clause is incorrect
Syntax is correct
Using WHERE instead of ON
Q52
Q52 What is the primary purpose of an index in a database?
To increase database size
To enhance data security
To speed up data retrieval
To transform data
Q53
Q53 What type of index would be most effective for a column that stores unique values in MySQL?
Primary index
Secondary index
Clustered index
Non-clustered index
Q54
Q54 Which MySQL engine supports FULLTEXT indexing?
MyISAM
InnoDB
Both
Neither
Q55
Q55 When is a composite index useful in MySQL?
When querying multiple columns frequently
Only with the PRIMARY KEY
For single-column searches
Never
Q56
Q56 What does the following SQL command do?
CREATE INDEX idx_name ON Customers (Name);
Creates a unique constraint on Name
Deletes an index on Name
Creates an index on the Name column
Alters the Name column
Q57
Q57 How does the query optimizer use indexes in MySQL?
To decide the best order to join tables
To reduce the use of disk space
To increase transaction speed
To automatically update table statistics
Q58
Q58 What is the effect of adding an index to a table on the performance of INSERT statements?
Slows down INSERTs
Speeds up INSERTs
No effect on INSERTs
INSERTs become unpredictable
Q59
Q59 Identify the error in this SQL statement:
CREATE INDEX ON Orders (OrderDate);
Missing index name
Syntax is correct
Should be a UNIQUE index
No column specified
Q60
Q60 What is wrong with this SQL command:
CREATE INDEX idx_product_id ON Products (ProductID) WHERE ProductID IS NULL;
MySQL does not support filtered indexes
Index name is incorrect
Syntax error in WHERE clause
All are correct