Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- drop table Apply;
- drop table Student;
- drop table College;
- create table College(cName varchar2(10) primary key, state
- varchar2(10), enrollment int);
- create table Student(sID int primary key, sName varchar2(10), GPA
- real, sizeHS int, DoB date);
- create table Apply(sID int, cName varchar2(10), major
- varchar2(20), decision char(1), primary key(sID, major, cName),
- constraint sID_fk Foreign key(sID) references Student, constraint
- cName_fk Foreign key(cName) references College);
- delete from Student;
- delete from College;
- delete from Apply;
- insert into Student values (123, 'Amy', 3.9, 1000, '26-JUN-96');
- insert into Student values (234, 'Bob', 3.6, 1500, '7-Apr-95');
- insert into Student values (345, 'Craig', 3.5, 500, '4-Feb-95');
- insert into Student values (456, 'Doris', 3.9, 1000, '24-Jul-97');
- insert into Student values (567, 'Edward', 2.9, 2000, '21-Dec-96');
- insert into Student values (678, 'Fay', 3.8, 200, '27-Aug-96');
- insert into Student values (789, 'Gary', 3.4, 800, '8-Oct-96');
- insert into Student values (987, 'Helen', 3.7, 800, '27-Mar-97');
- insert into Student values (876, 'Irene', 3.9, 400, '7-Mar-96');
- insert into Student values (765, 'Jay', 2.9, 1500, '8-Aug-98');
- insert into Student values (654, 'Amy', 3.9, 1000, '26-May-96');
- insert into Student values (543, 'Craig', 3.4, 2000, '27-Aug-05');
- insert into College values ('Stanford', 'CA', 15000);
- insert into College values ('Berkeley', 'CA', 36000);
- insert into College values ('MIT', 'MA', 10000);
- insert into College values ('Cornell', 'NY', 21000);
- insert into College values ('Harvard', 'MA', 50040);
- insert into Apply values (123, 'Stanford', 'CS', 'Y');
- insert into Apply values (123, 'Stanford', 'EE', 'N');
- insert into Apply values (123, 'Berkeley', 'CS', 'Y');
- insert into Apply values (123, 'Cornell', 'EE', 'Y');
- insert into Apply values (234, 'Berkeley', 'biology', 'N');
- insert into Apply values (345, 'MIT', 'bioengineering', 'Y');
- insert into Apply values (345, 'Cornell', 'bioengineering', 'N');
- insert into Apply values (345, 'Cornell', 'CS', 'Y');
- insert into Apply values (345, 'Cornell', 'EE', 'N');
- insert into Apply values (678, 'Stanford', 'history', 'Y');
- insert into Apply values (987, 'Stanford', 'CS', 'Y');
- insert into Apply values (987, 'Berkeley', 'CS', 'Y');
- insert into Apply values (876, 'Stanford', 'CS', 'N');
- insert into Apply values (876, 'MIT', 'biology', 'Y');
- insert into Apply values (876, 'MIT', 'marine biology', 'N');
- insert into Apply values (765, 'Stanford', 'history', 'Y');
- insert into Apply values (765, 'Cornell', 'history', 'N');
- insert into Apply values (765, 'Cornell', 'psychology', 'Y');
- insert into Apply values (543, 'MIT', 'CS', 'N');
- create view WeakStudent as select sid,sName from student where gpa<3.7;
- create view WeakStudent as select sid,sName from student where gpa<3.7;
- create or replace view WeakStudent as select sid, sName from student where gpa<3.7;
- select * from WeakStudent;
- create view cView(collegeName, seats) as select cname, enrollment from college;
- select * from cview;
- create view CSaccept as select sid, cname where major='CS' and decision='Y';
- create view CSaccept as select sid, cname where major='CS' and decision='Y' from apply;
- create view CSaccept as select sid, cname from apply where major='CS' and decision='Y';
- select * from CSaccept;
- drop table Apply;
- drop table Student;
- drop table College;
- create table College(cName varchar2(10) primary key, state
- varchar2(10), enrollment int);
- create table Student(sID int primary key, sName varchar2(10), GPA
- real, sizeHS int, DoB date);
- create table Apply(sID int, cName varchar2(10), major
- varchar2(20), decision char(1), primary key(sID, major, cName),
- constraint sID_fk Foreign key(sID) references Student, constraint
- cName_fk Foreign key(cName) references College);
- delete from Student;
- delete from College;
- delete from Apply;
- insert into Student values (123, 'Amy', 3.9, 1000, '26-JUN-96');
- insert into Student values (234, 'Bob', 3.6, 1500, '7-Apr-95');
- insert into Student values (345, 'Craig', 3.5, 500, '4-Feb-95');
- insert into Student values (456, 'Doris', 3.9, 1000, '24-Jul-97');
- insert into Student values (567, 'Edward', 2.9, 2000, '21-Dec-96');
- insert into Student values (678, 'Fay', 3.8, 200, '27-Aug-96');
- insert into Student values (789, 'Gary', 3.4, 800, '8-Oct-96');
- insert into Student values (987, 'Helen', 3.7, 800, '27-Mar-97');
- insert into Student values (876, 'Irene', 3.9, 400, '7-Mar-96');
- insert into Student values (765, 'Jay', 2.9, 1500, '8-Aug-98');
- insert into Student values (654, 'Amy', 3.9, 1000, '26-May-96');
- insert into Student values (543, 'Craig', 3.4, 2000, '27-Aug-05');
- insert into College values ('Stanford', 'CA', 15000);
- insert into College values ('Berkeley', 'CA', 36000);
- insert into College values ('MIT', 'MA', 10000);
- insert into College values ('Cornell', 'NY', 21000);
- insert into College values ('Harvard', 'MA', 50040);
- insert into Apply values (123, 'Stanford', 'CS', 'Y');
- insert into Apply values (123, 'Stanford', 'EE', 'N');
- insert into Apply values (123, 'Berkeley', 'CS', 'Y');
- insert into Apply values (123, 'Cornell', 'EE', 'Y');
- insert into Apply values (234, 'Berkeley', 'biology', 'N');
- insert into Apply values (345, 'MIT', 'bioengineering', 'Y');
- insert into Apply values (345, 'Cornell', 'bioengineering', 'N');
- insert into Apply values (345, 'Cornell', 'CS', 'Y');
- insert into Apply values (345, 'Cornell', 'EE', 'N');
- insert into Apply values (678, 'Stanford', 'history', 'Y');
- insert into Apply values (987, 'Stanford', 'CS', 'Y');
- insert into Apply values (987, 'Berkeley', 'CS', 'Y');
- insert into Apply values (876, 'Stanford', 'CS', 'N');
- insert into Apply values (876, 'MIT', 'biology', 'Y');
- insert into Apply values (876, 'MIT', 'marine biology', 'N');
- insert into Apply values (765, 'Stanford', 'history', 'Y');
- insert into Apply values (765, 'Cornell', 'history', 'N');
- insert into Apply values (765, 'Cornell', 'psychology', 'Y');
- insert into Apply values (543, 'MIT', 'CS', 'N');
- create or replace view WeakStudent as select sid, sName from student where gpa<3.7;
- select * from WeakStudent;
- create view cView(collegeName, seats) as select cname, enrollment from college;
- select * from cview;
- create view CSaccept as select sid, cname from apply where major='CS' and decision='Y';
- select * from CSaccept;
- select * from csaccept;
- select * from csaccept;
- select * from cview;
- select * from weakstudent;
- create view CSaccept as select sid, sname, gpa, sizehs, from college natural join apply where major='CS' and decision='Y';
- create view CSberkelry as select sid, sname, gpa, sizehs, from college natural join apply where major='CS' and decision='Y' and cname='berkeley' and sizehs>500;
- select * from CSaccept;
- create view CSberkelry as select sid, sname, gpa, sizehs, from college natural join csaccept where cname='berkeley' and sizehs>500;
- create view CSberkelry as select sid, sname, gpa, sizehs, from college natural join csaccept where cname='Berkeley' and sizehs>500;
- create view CSberkelry as select sid, sname, gpa, sizehs, from student natural join csaccept where cname='Berkeley' and sizehs>500;
- create view CSberkeley as select sid, sname, gpa, sizehs from student natural join csaccept where cname='Berkeley' and sizehs>500;
- select * from csberkeley;
- create or replace view CSBerkeley as select sid, sname, gpa, sizehs from student,apply where student.sid=apply.sid and major='CS' and decision='Y' and cname='Berkeley';
- create or replace view CSBerkeley as select sid, sname, gpa, sizehs from student,apply where student.sid=apply.sid and sizehs>500 and major='CS' and decision='Y' and cname='Berkeley';
- create or replace view CSBerkeley as select student.sid, sname, gpa, sizehs from student,apply where student.sid=apply.sid and sizehs>500 and major='CS' and decision='Y' and cname='Berkeley';
- select * from csberkeley;
- select * from csberkeley where gpa>3.8;
- drop view csaccept;
- drop table Apply;
- drop table Student;
- drop table College;
- create table College(cName varchar2(10) primary key, state
- varchar2(10), enrollment int);
- create table Student(sID int primary key, sName varchar2(10), GPA
- real, sizeHS int, DoB date);
- create table Apply(sID int, cName varchar2(10), major
- varchar2(20), decision char(1), primary key(sID, major, cName),
- constraint sID_fk Foreign key(sID) references Student, constraint
- cName_fk Foreign key(cName) references College);
- delete from Student;
- delete from College;
- delete from Apply;
- insert into Student values (123, 'Amy', 3.9, 1000, '26-JUN-96');
- insert into Student values (234, 'Bob', 3.6, 1500, '7-Apr-95');
- insert into Student values (345, 'Craig', 3.5, 500, '4-Feb-95');
- insert into Student values (456, 'Doris', 3.9, 1000, '24-Jul-97');
- insert into Student values (567, 'Edward', 2.9, 2000, '21-Dec-96');
- insert into Student values (678, 'Fay', 3.8, 200, '27-Aug-96');
- insert into Student values (789, 'Gary', 3.4, 800, '8-Oct-96');
- insert into Student values (987, 'Helen', 3.7, 800, '27-Mar-97');
- insert into Student values (876, 'Irene', 3.9, 400, '7-Mar-96');
- insert into Student values (765, 'Jay', 2.9, 1500, '8-Aug-98');
- insert into Student values (654, 'Amy', 3.9, 1000, '26-May-96');
- insert into Student values (543, 'Craig', 3.4, 2000, '27-Aug-05');
- insert into College values ('Stanford', 'CA', 15000);
- insert into College values ('Berkeley', 'CA', 36000);
- insert into College values ('MIT', 'MA', 10000);
- insert into College values ('Cornell', 'NY', 21000);
- insert into College values ('Harvard', 'MA', 50040);
- insert into Apply values (123, 'Stanford', 'CS', 'Y');
- insert into Apply values (123, 'Stanford', 'EE', 'N');
- insert into Apply values (123, 'Berkeley', 'CS', 'Y');
- insert into Apply values (123, 'Cornell', 'EE', 'Y');
- insert into Apply values (234, 'Berkeley', 'biology', 'N');
- insert into Apply values (345, 'MIT', 'bioengineering', 'Y');
- insert into Apply values (345, 'Cornell', 'bioengineering', 'N');
- insert into Apply values (345, 'Cornell', 'CS', 'Y');
- insert into Apply values (345, 'Cornell', 'EE', 'N');
- insert into Apply values (678, 'Stanford', 'history', 'Y');
- insert into Apply values (987, 'Stanford', 'CS', 'Y');
- insert into Apply values (987, 'Berkeley', 'CS', 'Y');
- insert into Apply values (876, 'Stanford', 'CS', 'N');
- insert into Apply values (876, 'MIT', 'biology', 'Y');
- insert into Apply values (876, 'MIT', 'marine biology', 'N');
- insert into Apply values (765, 'Stanford', 'history', 'Y');
- insert into Apply values (765, 'Cornell', 'history', 'N');
- insert into Apply values (765, 'Cornell', 'psychology', 'Y');
- insert into Apply values (543, 'MIT', 'CS', 'N');
- create or replace view WeakStudent as select sid, sName from student where gpa<3.7;
- select * from WeakStudent;
- create view cView(collegeName, seats) as select cname, enrollment from college;
- select * from cview;
- create view CSaccept as select sid, cname from apply where major='CS' and decision='Y';
- select * from CSaccept;
- select * from csaccept;
- select * from cview;
- select * from weakstudent;
- create view CSberkeley as select sid, sname, gpa, sizehs from student natural join csaccept where cname='Berkeley' and sizehs>500;
- create or replace view CSBerkeley as select student.sid, sname, gpa, sizehs from student,apply where student.sid=apply.sid and sizehs>500 and major='CS' and decision='Y' and cname='Berkeley';
- select * from csberkeley;
- select * from csberkeley where gpa>3.8;
- drop view csaccept;
- select sname from csberkeley;
- create or replace view WeakStudent as select sid, sName, gpa, sizehs, dob from student where gpa<3.7;
Add Comment
Please, Sign In to add comment