practical file class 11 (1)
practical file class 11 (1)
FILE
Subject: INFORMATICS PRACTICES
Code: 065
Data Management: SQL Commands
2. Write a SQL query to create “student” table with the student id, class, section,
gender, name, dob, and marks as attributes where the student id is the primary key.
Ans: CREATE TABLE Student ( ID Int primary key,
Class VARCHAR(100),
gender char
name text[20]
Dob date/time
Marks int );
Output:
Table: Student
ID (primary key) CLASS GENDER NAME DOB Marks
Insert into Student(ID, Class, Gender, Name, Dob) VALUES (2, 12, ‘M’, ‘Vikas’, 13-02-91, 75);
Insert into Student(ID, Class, Gender, Name, Dob) VALUES (3, 11, ‘F’, ‘Shikha’, 11-03-99, 70);
Insert into Student(ID, Class, Gender, Name, Dob) VALUES (4, 10, ‘M’, ‘Naman’, 12-08-93, 60);
Output:
Table: Student
ID (primary key) CLASS GENDER NAME DOB Marks
1 11 M Arun 19-02-93 50
2 12 M Vikas 13-02-91 75
3 11 F Shikha 11-03-99 70
4 10 M Naman 12-08-93 60
6. To increase marks by 5% for those students, who have Rno more than 20
Ans: UPDATE table Student Set Marks=Marks + (Marks x 5 /100) where ID > 20;
7. To display ID, Name & Marks of those students, who are scoring marks more than 50.
Ans: SELECT ID, Name, Marks from Student where marks> 50;
13. To display the information all the students, whose name starts with ‘A’.
Ans: SELECT * from Student where Name Like= “ A%”.
14. To display ID, Name of those students, who are born between ‘1990-01-01’ and
‘2000-01-01’
Ans : SELECT ID, Name from Student BETWEEN (1990-01-01) AND (2000-01-01)
15. To display ID, Name, DOB, Marks of those male students in ascending order of their
names.
Ans: SELECT ID, Name, Dob from Student ORDER by Name;
16. To display ID, Name, DOB, Marks of those male students in descending order of their
names.
Ans: SELECT ID, Name, Dob from Student ORDER by Name desc;