Worksheets › Class 12 › Structured Query Language (SQL)
Class 12 · Computer Science worksheetStructured Query Language (SQL)
CBSE Computer Science. DDL and DML, data types and constraints, SELECT with WHERE, BETWEEN, IN, LIKE, DISTINCT and ORDER BY, UPDATE and DELETE, on tables with computed results. Every sheet has 20 questions in three sections and an answer key, and the questions change every time.
Sample questions
Real questions from this chapter, as the app sets them. Tap Answer to see the answer and working.
Section A · multiple choice
- 1.
Which of these is a DDL command?
- UPDATE
- SELECT
- INSERT
- ALTER
Answer
(d) 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?
- 5
- 4
- 3
- 2
Answer
(c) 3
rows where Marks BETWEEN 58 AND 83
- 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?
- Ruler
- Diary
- Glue
- Notebook
Answer
(b) Diary
the matching rows, sorted: Diary, Crayons
Section B · short answer
- 4.
What is the difference between DDL and DML? Give two commands of each.
Answer
DDL defines and changes the structure of the database (CREATE, ALTER, DROP); DML works on the data (INSERT, UPDATE, DELETE, SELECT).
- 5.
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.
Answer
Name | Salary Rohan | 28000 Rahul | 57000
rows where Name LIKE 'R%', sorted on Salary
Section C · long answer
- 6.
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).
Answer
CREATE TABLE STUDENT (RollNo INT PRIMARY KEY, Name VARCHAR(20) NOT NULL, Sec CHAR(1), Marks INT);
Fresh sheets for your child
In the app, every Structured Query Language (SQL) sheet is new: the app remembers the questions your child has already had and leaves them out. Print the sheet as a PDF, or use notebook mode and write the answers in a notebook.
Coming soon for Android and iPhone.