0% found this document useful (0 votes)
78 views3 pages

CBSE Class 12 SQL Practical Guide

The document outlines SQL practical file questions for CBSE Class 12 IT (802), including commands for creating a database and table, inserting records, displaying data, and performing various SQL operations such as updates, deletions, and aggregations. It also covers advanced topics like constraints, foreign keys, and join queries. The document provides specific SQL commands for each task, making it a comprehensive guide for students to practice SQL skills.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views3 pages

CBSE Class 12 SQL Practical Guide

The document outlines SQL practical file questions for CBSE Class 12 IT (802), including commands for creating a database and table, inserting records, displaying data, and performing various SQL operations such as updates, deletions, and aggregations. It also covers advanced topics like constraints, foreign keys, and join queries. The document provides specific SQL commands for each task, making it a comprehensive guide for students to practice SQL skills.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CBSE Class 12 IT (802) – SQL Practical File Questions

1. Create a Database
Write SQL commands to create a database named school.

CREATE DATABASE school;

2. Create a Table
Create a table student with fields: admno, name, class, section, marks.

CREATE TABLE student (


admno INT PRIMARY KEY,
name VARCHAR(30),
class INT,
section CHAR(1),
marks INT
);

3. Insert Records
Insert five records into the student table.

INSERT INTO student VALUES


(101, 'Amit', 12, 'A', 88),
(102, 'Riya', 12, 'A', 92),
(103, 'Sohan', 12, 'B', 76),
(104, 'Anita', 12, 'B', 85),
(105, 'Keshav', 12, 'A', 90);

4. Display All Records


SELECT * FROM student;

5. WHERE Clause
SELECT * FROM student WHERE marks > 85;

6. Sorting Data
SELECT * FROM student ORDER BY marks DESC;

7. DISTINCT
SELECT DISTINCT section FROM student;

8. Updating a Record
UPDATE student SET marks = marks + 5 WHERE admno = 103;
9. Deleting a Record
DELETE FROM student WHERE admno = 104;

10. Aggregate Functions


SELECT MAX(marks), MIN(marks), AVG(marks) FROM student;

11. Counting Records


SELECT COUNT(*) FROM student WHERE class = 12;

12. GROUP BY
SELECT section, AVG(marks) FROM student GROUP BY section;

13. LIKE Operator


SELECT * FROM student WHERE name LIKE 'A%';

14. BETWEEN Operator


SELECT * FROM student WHERE marks BETWEEN 80 AND 95;

15. ALTER TABLE


ALTER TABLE student ADD dob DATE;

16. DROP COLUMN


ALTER TABLE student DROP COLUMN section;

17. Constraints
CREATE TABLE teacher (
tid INT PRIMARY KEY,
name VARCHAR(30) NOT NULL,
phone VARCHAR(10) UNIQUE
);

18. Foreign Key


CREATE TABLE fees (
receipt INT PRIMARY KEY,
admno INT,
amount INT,
FOREIGN KEY (admno) REFERENCES student(admno)
);

19. Join Query


SELECT [Link], [Link] FROM student
JOIN fees ON [Link] = [Link];
20. Output Question
SELECT name, marks FROM student WHERE marks >= 90;
Expected Output: Riya, Keshav

You might also like