Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

MY SQL Chapter-3

Total questions: 20

Worksheet time: 3mins

Name
Class
Date
1.

Identify the error in this SQL statement: INSERT INTO Order (ID, Product) VALUES (101, 'Laptop');

a)

Table name should be Orders

b)

Syntax is correct

c)

Missing semicolon at the end

d)

The Product column does not exist

2.

What is the purpose of the VARCHAR data type in MySQL?

a)

To store fixed-length strings

b)

To store variable-length strings

c)

To store large text objects

d)

To store integers

3.

Which data type would be best for storing an email address?

a)

CHAR(50)

b)

VARCHAR(100)

c)

TEXT

d)

BLOB

4.

What is the main difference between CHAR and VARCHAR data types in MySQL?

a)

CHAR stores binary data, VARCHAR does not

b)

CHAR has unlimited length, VARCHAR is limited

c)

CHAR is variable-length, VARCHAR is fixed-length

d)

CHAR is fixed-length, VARCHAR is variable-length

5.

What does the following SQL command achieve? CREATE TABLE Orders (OrderID INT, OrderDate DATETIME DEFAULT CURRENT_TIMESTAMP);

a)

Creates a table with two columns without defaults

b)

Creates a table and sets a default timestamp for OrderDate

c)

Creates a table and makes OrderDate a primary key

d)

None of the above

6.

What is incorrect in the following SQL statement? CREATE TABLE Users (ID INT, Name CHAR(20), Email VARHCAR(100));

a)

Spelling mistake in data type for Email

b)

ID should be VARCHAR

c)

Name should be TEXT

d)

Syntax is correct

7.

What does the UPDATE statement do in SQL?

a)

Deletes records

b)

Modifies existing records

c)

Inserts new records

d)

Creates a table

8.

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

9.

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

10.

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

11.

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

12.

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

13.

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

14.

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

15.

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

16.

Spot the error in this SQL statement: CREATE VIEW SalesSummary AS SELECT ProductID, SUM(Quantity) FROM Sales GROUP BY ProductID HAVING SUM(Quantity) > 100;

a)

Missing alias for SUM(Quantity)

b)

Syntax is correct

c)

HAVING clause is unnecessary

d)

Grouping by ProductID is not allowed

17.

Which of the following commands are a part of Data Control Language?

a)

Revoke

b)

Grant

c)

Both A and B

d)

None of the above

18.

Which of the following is the full form of DDL?

a)

Data definition language

b)

Data derivation language

c)

Dynamic data language

d)

Detailed data language

19.

What are rows of a relation known as?

a)

Degree

b)

Entity

c)

Tuple

d)

None

20.

Which of the following is not a valid SQL type?

a)

NUMERIC

b)

DECIMAL

c)

CHARACTER

d)

None of the above