Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
1 views4 pages

SQL Worksheet

Uploaded by

arifa20387
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views4 pages

SQL Worksheet

Uploaded by

arifa20387
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

SQL Worksheet

A. Fill in the Blanks (10 questions)


1. SQL stands for __________.
2. The command used to create a database is __________.
3. The __________ clause is used to sort the result in ascending or descending order.
4. The default sorting order in SQL is __________.
5. __________ is used to remove all records from a table but not the structure.
6. The __________ constraint ensures that a column cannot have duplicate values.
7. In SQL, the __________ function is used to count the total number of rows in a table.
8. The command __________ is used to add a new column in an existing table.
9. In SQL, varchar(n) stores __________ length characters up to n.
10. The __________ operator is used to compare a value with a range of values.
B. True or False (10 questions)
11. DROP DATABASE deletes both the structure and data of the database. (T/F)
12. NOT NULL allows NULL values in a column. (T/F)
13. SQL is a case-sensitive language. (T/F)
14. The LIKE operator is used for pattern matching. (T/F)
15. ALTER TABLE can be used to delete a column from a table. (T/F)
16. PRIMARY KEY allows duplicate values. (T/F)
17. The UPDATE command is a part of Data Manipulation Language. (T/F)
18. In SQL, DISTINCT removes duplicate records from a query result. (T/F)
19. INT and FLOAT are character data types. (T/F)
20. The IS NULL operator checks whether a column value is empty. (T/F)
C. Objective Questions (Multiple Choice / One-word) (10 questions)
21. Which of the following is a DDL command?
a) SELECT b) INSERT c) CREATE d) UPDATE
22. Which of the following is NOT an aggregate function?
a) SUM b) AVG c) MAX d) BETWEEN
23. Which clause is used to eliminate duplicate rows?
a) UNIQUE b) DISTINCT c) ORDER BY d) GROUP BY
24. Default order of ORDER BY is:
a) Ascending b) Descending c) Random d) None
25. Which operator is used for logical AND in SQL?
a) && b) AND c) || d) ALL
26. Which constraint automatically enforces NOT NULL + UNIQUE?
a) Foreign Key b) Primary Key c) Check d) Default
27. Which SQL command is used to delete a table permanently?
a) DELETE b) DROP c) REMOVE d) TRUNCATE
28. Which of the following represents a floating-point data type?
a) INT b) FLOAT c) VARCHAR d) CHAR
29. Which clause is used to filter records?
a) WHERE b) HAVING c) ORDER BY d) GROUP BY
30. Which SQL command is used to change existing values in a table?
a) INSERT b) UPDATE c) DELETE d) ALTER
D. Assertion and Reason (5 questions)
a) Both A and R are true, and R is the correct explanation of A
b) Both A and R are true, but R is not the correct explanation of A
c) A is true, R is false
d) A is false, R is true
31. Assertion (A): PRIMARY KEY can have multiple NULL values.
Reason (R): A PRIMARY KEY uniquely identifies each record.
32. Assertion (A): DELETE removes rows one by one.
Reason (R): TRUNCATE is faster than DELETE.
33. Assertion (A): The LIKE operator is used for exact matching.
Reason (R): LIKE uses wildcard characters % and _.
34. Assertion (A): DISTINCT is used to remove duplicate rows in query results.
Reason (R): By default, SQL allows duplicate rows in output.
35. Assertion (A): ALTER TABLE can add or drop a column.
Reason (R): It cannot be used to rename a table.
E. Practical SQL Questions (Based on a Table) (10 questions)
36. Consider the following table: STUDENT
RollNo Name Class Marks City
1 Rohan 10 85 Delhi
2 Neha 10 92 Mumbai
3 Amit 11 76 Delhi
4 Meena 11 89 Chennai
5 Arjun 12 95 Delhi
1. Write a query to display all student names and marks.

2. Write a query to find students who scored more than 90 marks.

3. Write a query to display all distinct cities from the table.

4. Write a query to arrange students in descending order of marks.

5. Write a query to count the number of students from Delhi.

6. Write a query to update marks of Rohan to 90.


7. Write a query to delete the record of student with RollNo = 3.

8. Write a query to find the highest marks.

9. Write a query to find the average marks of Class 10 students.

10. Write a query to display names of students whose name starts with ‘M’.

F. Command to Output (5 questions)


11. Query: SELECT COUNT(*) FROM STUDENT;

12. Query: SELECT MAX(Marks) FROM STUDENT;

13. Query: SELECT Name FROM STUDENT WHERE City='Delhi';

14. Query: SELECT Name, Marks FROM STUDENT WHERE Marks BETWEEN 80 AND 90;
15. Query: SELECT DISTINCT Class FROM STUDENT;

You might also like