WorksheetsMY SQL Chapter-3
Total questions: 20
Worksheet time: 3mins
Identify the error in this SQL statement: INSERT INTO Order (ID, Product) VALUES (101, 'Laptop');
Table name should be Orders
Syntax is correct
Missing semicolon at the end
The Product column does not exist
What is the purpose of the VARCHAR data type in MySQL?
To store fixed-length strings
To store variable-length strings
To store large text objects
To store integers
Which data type would be best for storing an email address?
CHAR(50)
VARCHAR(100)
TEXT
BLOB
What is the main difference between CHAR and VARCHAR data types in MySQL?
CHAR stores binary data, VARCHAR does not
CHAR has unlimited length, VARCHAR is limited
CHAR is variable-length, VARCHAR is fixed-length
CHAR is fixed-length, VARCHAR is variable-length
What does the following SQL command achieve? CREATE TABLE Orders (OrderID INT, OrderDate DATETIME DEFAULT CURRENT_TIMESTAMP);
Creates a table with two columns without defaults
Creates a table and sets a default timestamp for OrderDate
Creates a table and makes OrderDate a primary key
None of the above
What is incorrect in the following SQL statement? CREATE TABLE Users (ID INT, Name CHAR(20), Email VARHCAR(100));
Spelling mistake in data type for Email
ID should be VARCHAR
Name should be TEXT
Syntax is correct
What does the UPDATE statement do in SQL?
Deletes records
Modifies existing records
Inserts new records
Creates a table
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
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
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
Which type of JOIN returns only the rows that have a match in both joined tables?
LEFT JOIN
RIGHT JOIN
INNER JOIN
FULL JOIN
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
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
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
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
Spot the error in this SQL statement: CREATE VIEW SalesSummary AS SELECT ProductID, SUM(Quantity) FROM Sales GROUP BY ProductID HAVING SUM(Quantity) > 100;
Missing alias for SUM(Quantity)
Syntax is correct
HAVING clause is unnecessary
Grouping by ProductID is not allowed
Which of the following commands are a part of Data Control Language?
Revoke
Grant
Both A and B
None of the above
Which of the following is the full form of DDL?
Data definition language
Data derivation language
Dynamic data language
Detailed data language
What are rows of a relation known as?
Degree
Entity
Tuple
None
Which of the following is not a valid SQL type?
NUMERIC
DECIMAL
CHARACTER
None of the above
