DBMS
DBMS
DBMS
cName varchar2(10),
state varchar2(10),
enrollment int
);
create table Student(
sID int,
sName varchar2(10),
GPA number(2,1),
sizeHS int,
DoB date
);
create table Apply(
sID int,
cName varchar2(10),
major varchar2(20),
decision char(1)
);
College Table
3. List the name of student whose High School size is atleast 1000 and born
after 1996. [Hint: check DoB greater than 31st December, 1996]
Ans- Select sName from Student
where sizeHS>=1000 and DoB>'31-Dec-1996';
4. List the name of student who are scoring GPA in between 2.9 and 3.9
Ans- Select sName from Student
where GPA between 2.9 and 3.9;
7. List the students who have born after 1st Jul 96 in the order of the Date of
Birth.
where decision='Y';
where cName='Stanford';
10. List the colleges that that has enrollment greater than 10001.
where enrollment>10001;
where state!='CA';
12. List names of all student who came from high school having size greater
desc Student;
16. List the student names those are having three characters in their Names.
Select sName from Student
where sName like '___';
17. List the student names those are starting with ‘H’ and with five characters.
Select sName from Student
where sName like 'H____';
18. List the student names those are having third character and fifth char. must
be ‘e’.
Select sName from Student
where sName like '__e_e%';
21. List the details of the students in order of the ascending of GPA and
descending of DoB.
Select * from Student
order by GPA , DoB desc;
22. List the sIDs of student who apply in either ‘Stanford’, ‘Cornell’ or ‘MIT’
College.
Select sID from Apply
where cName='Stanford' or cName='Cornell' or cName='MIT';
23. Delete all applications filled at Stanford (Choose table wisely)
Delete from Apply
where cName='Stanford';
25. Modify the GPA of all students by giving 10% raise in their GPA.
Update Student
Set GPA=GPA+0.10*GPA;
26. Increment the GPA of the students by 1.5 whose GPA is less than 3.5 and
belong to High School having size greater than 1500.
Update Student
Set GPA=GPA+1.5
where GPA<3.5 and sizeHS>1500;
27. Delete the students who have scored less than 3.2 GPA.
Delete from Student
where GPA<3.2;
Assignment 2
(iv) Make sID in Apply foreign key referring table student and
cName referring
table college.
Alter table Apply add constraint fs foreign key(sID) references
Student (sID) add constraint fc foreign key(cName) references
College(cName);