AmbifulWorksheets
Practice that never repeats
CBSE · Class 12 · Computer Science

Structured Query Language (SQL)

Standard difficulty · 20 questions · 40 marks · Time: 45 minutes

Name: Date: Score: ____ / 40

Show your working for Sections B and C. Answers are on the last page — try every question first!

Section A — Choose the correct answer8 × 1 = 8 marks
1.
Which of these is a DDL command?
  1. UPDATE
  2. SELECT
  3. INSERT
  4. ALTER
2.
Table: STUDENT
RollNo | Name | Sec | City | Marks
101 | Dev | C | Delhi | 47
102 | Ananya | A | Delhi | 58
103 | Zoya | B | Delhi | 92
104 | Isha | B | Delhi | 46
105 | Vikram | C | Indore | 68
106 | Rahul | C | Pune | 40
107 | Priya | C | Delhi | 96
108 | Kabir | A | Indore | 83

SELECT Name, Marks FROM STUDENT WHERE Marks BETWEEN 58 AND 83;
How many rows does this query return?
  1. 5
  2. 4
  3. 3
  4. 2
3.
Table: ITEM
ICode | IName | Category | Price | Qty
I01 | Folder | Paper | 280 | 120
I02 | Crayons | Writing | 290 | 95
I03 | Pencil | Writing | 45 | 50
I04 | Ruler | Desk | 210 | 95
I05 | Glue | Desk | 230 | 70
I06 | Sharpener | Desk | 155 | 115
I07 | Notebook | Paper | 225 | 55
I08 | Diary | Paper | 160 | 95

SELECT IName FROM ITEM WHERE IName LIKE '__a%' AND Category IN ('Writing', 'Paper') ORDER BY Price;
What is the first value in the first column of the result?
  1. Ruler
  2. Diary
  3. Glue
  4. Notebook
4.
Table: ITEM
ICode | IName | Category | Price | Qty
I01 | Glue | Desk | 275 | 120
I02 | Diary | Paper | 100 | 135
I03 | Folder | Paper | 110 | 90
I04 | Crayons | Writing | 155 | 50
I05 | Ruler | Desk | 265 | 80
I06 | Marker | Writing | 40 | 35
I07 | Stapler | Desk | 150 | 75
I08 | Pen | Writing | 230 | 140

SELECT DISTINCT Category FROM ITEM ORDER BY Category;
How many rows does this query return?
  1. 4
  2. 8
  3. 3
  4. 2
5.
Table: ITEM
ICode | IName | Category | Price | Qty
I01 | Pencil | Writing | 10 | 135
I02 | Notebook | Paper | 150 | 40
I03 | Ruler | Desk | 195 | 45
I04 | Eraser | Desk | 180 | 25
I05 | Glue | Desk | 275 | 105
I06 | Pen | Writing | 35 | 15
I07 | Sharpener | Desk | 205 | 130

UPDATE ITEM SET Price = Price + 5 WHERE Price BETWEEN 35 AND 205;
How many rows does this statement change?
  1. 5
  2. 6
  3. 2
  4. 4
6.
What does the SQL command DROP TABLE do?
  1. DDL: removes a table with its data
  2. lists the tables of the current database
  3. DML: changes values in existing rows
  4. makes a database the current one
7.
Table: STUDENT
RollNo | Name | Sec | City | Marks
101 | Zoya | A | Kochi | 73
102 | Isha | B | Pune | 91
103 | Meera | B | Kochi | 52
104 | Dev | A | Pune | 64
105 | Priya | B | Shimla | 40
106 | Vikram | C | Shimla | 46

SELECT Name, Marks FROM STUDENT WHERE Marks <= 64;
If the WHERE clause were changed to WHERE NOT (Marks <= 64), how many rows would the query return?
  1. 3
  2. 6
  3. 2
  4. 4
8.
Table: ITEM
ICode | IName | Category | Price | Qty
I01 | Stapler | Desk | 70 | 145
I02 | Glue | Desk | 215 | 130
I03 | Sharpener | Desk | 65 | 110
I04 | Notebook | Paper | 20 | 40
I05 | Pencil | Writing | 290 | 85
I06 | Marker | Writing | 180 | 120
I07 | Folder | Paper | 25 | 115
I08 | Pen | Writing | 150 | 150
After ALTER TABLE ITEM ADD Remarks VARCHAR(30); what is the degree of ITEM?
  1. 8
  2. 6
  3. 7
  4. 5
Section B — Short answer8 × 2 = 16 marks
9.
What is the difference between DDL and DML? Give two commands of each.
10.
Table: EMPLOYEE
EmpNo | Name | Dept | Salary | Bonus
E1 | Arjun | Sales | 72000 | 1000
E2 | Rahul | Accounts | 57000 | 5500
E3 | Vikram | Sales | 49000 | 2500
E4 | Asha | Accounts | 43000 | 6000
E5 | Zoya | Sales | 85000 | 9500
E6 | Meera | Accounts | 77000 | NULL
E7 | Priya | IT | 47000 | 2500
E8 | Rohan | IT | 28000 | 2500

SELECT Name, Salary FROM EMPLOYEE WHERE Name LIKE 'R%' ORDER BY Salary;
Write the output.
11.
Table: EMPLOYEE
EmpNo | Name | Dept | Salary | Bonus
E1 | Rohan | Sales | 80000 | 3500
E2 | Rahul | Accounts | 67000 | 4500
E3 | Isha | IT | 45000 | 6500
E4 | Vikram | Sales | 83000 | 10000
E5 | Priya | Sales | 82000 | NULL
E6 | Meera | Sales | 71000 | 3000
E7 | Arjun | Sales | 88000 | NULL

SELECT Name FROM EMPLOYEE WHERE Salary BETWEEN 45000 AND 83000 AND Dept = 'Accounts' ORDER BY Salary DESC;
Write the values in the output, in order, separated by commas.
12.
Table: STUDENT
RollNo | Name | Sec | City | Marks
101 | Rahul | C | Kochi | 62
102 | Arjun | B | Indore | 81
103 | Zoya | B | Kochi | 61
104 | Isha | C | Kochi | 43
105 | Rohan | B | Pune | 65
106 | Ananya | B | Pune | 86
107 | Kabir | A | Indore | 51
108 | Priya | A | Kochi | 40

SELECT DISTINCT Sec FROM STUDENT ORDER BY Sec;
Write the output.
13.
Table: STUDENT
RollNo | Name | Sec | City | Marks
101 | Priya | A | Jaipur | 75
102 | Arjun | A | Delhi | 84
103 | Asha | C | Shimla | 52
104 | Kabir | C | Jaipur | 74
105 | Vikram | A | Delhi | 89
106 | Rahul | B | Delhi | 40
107 | Meera | C | Delhi | 46
108 | Zoya | C | Delhi | 49

UPDATE STUDENT SET Marks = Marks + 25 WHERE Marks >= 46;
SELECT SUM(Marks) FROM STUDENT;
What does the SELECT return after the UPDATE?
14.
Table: STUDENT
RollNo | Name | Sec | City | Marks
1 | Ananya | B | Jaipur | 96
2 | Kabir | B | Jaipur | 60
3 | Vikram | A | Jaipur | 93
4 | Arjun | B | Shimla | 56
5 | Rahul | C | Jaipur | 42
6 | Meera | B | Kochi | 81
7 | Zoya | C | Kochi | 71
8 | Priya | B | Kochi | 48
Write an SQL query to display the names of students whose name begins with A.
15.
Table: STUDENT
RollNo | Name | Sec | City | Marks
201 | Ananya | A | Pune | 88
202 | Dev | B | Pune | 56
203 | Arjun | A | Delhi | 95
204 | Vikram | C | Shimla | 73
205 | Isha | A | Shimla | 96
206 | Rahul | A | Delhi | 64
207 | Meera | C | Delhi | 80
208 | Zoya | A | Shimla | 46

SELECT Name, Marks FROM STUDENT WHERE Marks BETWEEN 46 AND 64 AND Sec NOT IN ('C', 'A');
How many rows does this query return?
16.
Is DROP TABLE a DDL or a DML command?
Section C — Word problems4 × 4 = 16 marks
17.
Write the SQL command to create a table STUDENT with RollNo (integer, primary key), Name (up to 20 characters, not null), Sec (one character) and Marks (integer).
18.
Write the output of each query.
(a)
Table: STUDENT
RollNo | Name | Sec | City | Marks
1 | Isha | A | Indore | 57
2 | Dev | A | Jaipur | 74
3 | Asha | C | Jaipur | 84
4 | Rahul | B | Indore | 62
5 | Priya | C | Pune | 48
6 | Zoya | C | Jaipur | 69

SELECT Name, Marks FROM STUDENT WHERE Name LIKE 'R%' ORDER BY Marks DESC;
(b)
Table: EMPLOYEE
EmpNo | Name | Dept | Salary | Bonus
E1 | Zoya | Accounts | 67000 | 4000
E2 | Meera | Sales | 28000 | NULL
E3 | Arjun | HR | 35000 | 4000
E4 | Isha | Accounts | 57000 | NULL
E5 | Asha | Accounts | 37000 | 8000
E6 | Kabir | Accounts | 80000 | 5500
E7 | Vikram | HR | 77000 | 9500
E8 | Dev | HR | 30000 | 4000

SELECT DISTINCT Dept FROM EMPLOYEE ORDER BY Dept;
19.
Table: ITEM
ICode | IName | Category | Price | Qty
I01 | Notebook | Paper | 215 | 150
I02 | Pencil | Writing | 145 | 110
I03 | Crayons | Writing | 70 | 135
I04 | Stapler | Desk | 290 | 50
I05 | Eraser | Desk | 15 | 55
I06 | Pen | Writing | 185 | 125
I07 | Sharpener | Desk | 55 | 65
I08 | Folder | Paper | 295 | 70
Write SQL statements to (a) display the names and prices of items in the Paper category, cheapest first; (b) increase the price of every item costing less than 295 by 5; (c) add a column Discount of type INT; (d) remove the items whose quantity is more than 100.
20.
Table: EMPLOYEE
EmpNo | Name | Dept | Salary | Bonus
E1 | Priya | IT | 73000 | 2000
E2 | Arjun | IT | 31000 | 9500
E3 | Vikram | HR | 84000 | 2500
E4 | Meera | IT | 69000 | NULL
E5 | Rohan | Accounts | 67000 | 2000
E6 | Zoya | HR | 60000 | 10000
E7 | Dev | Accounts | 45000 | 10000

UPDATE EMPLOYEE SET Salary = Salary + 5000 WHERE Dept NOT IN ('Accounts', 'IT') AND Salary BETWEEN 31000 AND 73000;
(a) How many rows does this statement change? (b) What does SELECT SUM(Salary) FROM EMPLOYEE; return after it? (c) Is it a DDL or DML command? Why?
AmbifulWorksheets
Practice that never repeats
CBSE · Class 12 · Computer Science

Answer key

Structured Query Language (SQL) · AW-12CS-SQL-2026-V1 · For parents — fold back or tear off before handing the sheet to your child.

QAnswerWorking
1(d) ALTER—
2(c) 3rows where Marks BETWEEN 58 AND 83
3(b) Diarythe matching rows, sorted: Diary, Crayons
4(c) 3DISTINCT keeps one of each value: Desk, Paper, Writing
5(a) 5rows where Price BETWEEN 35 AND 205
6(a) DDL: removes a table with its data—
7(c) 26 rows in all, 4 match the original condition
8(b) 6one new column; existing rows get NULL in it
9DDL defines and changes the structure of the database (CREATE, ALTER, DROP); DML works on the data (INSERT, UPDATE, DELETE, SELECT).—
10Name | Salary
Rohan | 28000
Rahul | 57000
rows where Name LIKE 'R%', sorted on Salary
11Rahulrows where Salary BETWEEN 45000 AND 83000 AND Dept = 'Accounts'
12Sec
A
B
C
DISTINCT removes repeated values; ORDER BY sorts them
136847 rows changed, then the column is added up
14SELECT Name FROM STUDENT WHERE Name LIKE 'A%';SELECT columns FROM table WHERE condition ORDER BY column
151rows where Marks BETWEEN 46 AND 64 AND Sec NOT IN ('C', 'A')
16DDLDDL: removes a table with its data
17CREATE TABLE STUDENT (RollNo INT PRIMARY KEY, Name VARCHAR(20) NOT NULL, Sec CHAR(1), Marks INT);—
18(a)
Name | Marks
Rahul | 62
(b)
Dept
Accounts
HR
Sales
Name LIKE 'R%'; DISTINCT keeps one of each value
19(a) SELECT IName, Price FROM ITEM WHERE Category = 'Paper' ORDER BY Price; (b) UPDATE ITEM SET Price = Price + 5 WHERE Price < 295; (c) ALTER TABLE ITEM ADD Discount INT; (d) DELETE FROM ITEM WHERE Qty > 100;SELECT/UPDATE/DELETE are DML; ALTER TABLE is DDL
20(a) 1; (b) 434000; (c) DML: it changes the data in the table, not its structure.rows where Dept NOT IN ('Accounts', 'IT') AND Salary BETWEEN 31000 AND 73000