Sunteți pe pagina 1din 9

SQL> 2 3 4 5 6

create table student54 ( rollno varchar2(8) primary key, sname varchar2(30), birthdate date );

Table created. SQL> 2 3 4 5 6 7 8 create table course54 ( cno varchar2(6) primary key, cname varchar2(20), coursefee number(8), duration number(3), check(coursefee>0) );

Table created. SQL> 2 3 4 SQL> 2 3 4 5 6 create table studcourse54 ( rollno create table stud_course54 ( rollno varchar2(8)references student54, cno varchar2(6)references course54, primary key(rollno,cno) );

Table created. SQL> insert into student values('&rollno','&sname','&birthdate'); Enter value for rollno: 1 Enter value for sname: rutuja Enter value for birthdate: 06_may_1992 old 1: insert into student values('&rollno','&sname','&birthdate') new 1: insert into student values('1','rutuja','06_may_1992') insert into student values('1','rutuja','06_may_1992') * ERROR at line 1: ORA-00947: not enough values SQL> / Enter value for rollno: 1 Enter value for sname: rutuja Enter value for birthdate: 06-may-1991 old 1: insert into student values('&rollno','&sname','&birthdate') new 1: insert into student values('1','rutuja','06-may-1991') insert into student values('1','rutuja','06-may-1991') * ERROR at line 1: ORA-00947: not enough values SQL> / Enter value for rollno: 1 Enter value for sname: rutuja

Enter value for birthdate: 06-jun-1991 old 1: insert into student values('&rollno','&sname','&birthdate') new 1: insert into student values('1 ','rutuja ','06-jun-1991') insert into student values('1 ','rutuja ','06-jun-1991') * ERROR at line 1: ORA-00947: not enough values SQL> insert into student054 values('&rollno','&sname','&birthdate'); Enter value for rollno: 1 Enter value for sname: rutuja Enter value for birthdate: 06-jun-1991 old 1: insert into student054 values('&rollno','&sname','&birthdate') new 1: insert into student054 values('1','rutuja','06-jun-1991') insert into student054 values('1','rutuja','06-jun-1991') * ERROR at line 1: ORA-00942: table or view does not exist SQL> insert into student54 values('&rollno','&sname','&birthdate'); Enter value for rollno: 1 Enter value for sname: rutuja Enter value for birthdate: 06-jun-1991 old 1: insert into student54 values('&rollno','&sname','&birthdate') new 1: insert into student54 values('1','rutuja ','06-jun-1991') 1 row created. SQL> / Enter value for Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> / Enter value for Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> / Enter value for Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> / Enter value for rollno: 5 Enter value for sname: hiral rollno: 4 sname: sweety birthdate: 04-dec-1994 into student54 values('&rollno','&sname','&birthdate') into student54 values('4','sweety','04-dec-1994') rollno: 3 sname: neha birthdate: 03-mar-1993 into student54 values('&rollno','&sname','&birthdate') into student54 values('3','neha','03-mar-1993') rollno: 2 sname: sneha birthdate: 02-may-1992 into student54 values('&rollno','&sname','&birthdate') into student54 values('2','sneha','02-may-1992')

Enter value for birthdate: 05-apr-1995 old 1: insert into student54 values('&rollno','&sname','&birthdate') new 1: insert into student54 values('5','hiral','05-apr-1995') 1 row created. SQL> select * from student54; ROLLNO -------1 2 3 4 5 SNAME -----------------------------rutuja sneha neha sweety hiral BIRTHDATE --------06-JUN-91 02-MAY-92 03-MAR-93 04-DEC-94 05-APR-95

SQL> insert into course values('&cno','&cname','&coursefee','&duration'); Enter value for cno: c1 Enter value for cname: c++ Enter value for coursefee: 3000 Enter value for duration: 11 old 1: insert into course values('&cno','&cname','&coursefee','&duration') new 1: insert into course values('c1','c++','3000','11') 1 row created. SQL> / Enter value for Enter value for Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> / Enter value for Enter value for Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> / Enter value for Enter value for Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> / Enter value for cno: c5 Enter value for cname: stat Enter value for coursefee: 3000 cno: c4 cname: oracel coursefee: 2000 duration: 2 into course values('&cno','&cname','&coursefee','&duration') into course values('c4','oracel','2000','2') cno: c3 cname: java coursefee: 4000 duration: 6 into course values('&cno','&cname','&coursefee','&duration') into course values('c3','java','4000','6') cno: c2 cname: c coursefee: 2000 duration: 5 into course values('&cno','&cname','&coursefee','&duration') into course values('c2','c','2000','5')

Enter value for duration: 2 old 1: insert into course values('&cno','&cname','&coursefee','&duration') new 1: insert into course values('c5','stat','3000','2') 1 row created. SQL> select * from course54; no rows selected SQL> Enter Enter Enter Enter old new insert into course54 values('&cno','&cname','&coursefee','&duration'); value for cno: c1 value for cname: c value for coursefee: 5000 value for duration: 5 1: insert into course54 values('&cno','&cname','&coursefee','&duration') 1: insert into course54 values('c1','c','5000','5')

1 row created. SQL> / Enter value for cno: c2 Enter value for cname: c++ Enter value for coursefee: 5000 Enter value for duration: 4 old 1: insert into course54 values('&cno','&cname','&coursefee','&duration') new 1: insert into course54 values('c2','c++','5000','4') 1 row created. SQL> / Enter value for cno: c3 Enter value for cname: java Enter value for coursefee: 4000 Enter value for duration: 5 old 1: insert into course54 values('&cno','&cname','&coursefee','&duration') new 1: insert into course54 values('c3','java','4000','5') 1 row created. SQL> / Enter value for cno: c4 Enter value for cname: stat Enter value for coursefee: 3000 Enter value for duration: 3 old 1: insert into course54 values('&cno','&cname','&coursefee','&duration') new 1: insert into course54 values('c4','stat','3000','3') 1 row created. SQL> / Enter value for cno: c5 Enter value for cname: oracel Enter value for coursefee: 4000 Enter value for duration: 4 old 1: insert into course54 values('&cno','&cname','&coursefee','&duration') new 1: insert into course54 values('c5','oracel','4000','4') 1 row created.

SQL> select * from course54; CNO -----c1 c2 c3 c4 c5 CNAME COURSEFEE DURATION -------------------- --------- --------c 5000 5 c++ 5000 4 java 4000 5 stat 3000 3 oracel 4000 4

SQL> insert into studcourse54; insert into studcourse54 * ERROR at line 1: ORA-00926: missing VALUES keyword SQL> insert into studcourse54 valuse('&rollno','&cno'); Enter value for rollno: 1 Enter value for cno: c1 old 1: insert into studcourse54 valuse('&rollno','&cno') new 1: insert into studcourse54 valuse('1','c1') insert into studcourse54 valuse('1','c1') * ERROR at line 1: ORA-00928: missing SELECT keyword SQL> insert into studcourse54 values('&rollno','&cno'); Enter value for rollno: c1 Enter value for cno: 1 old 1: insert into studcourse54 values('&rollno','&cno') new 1: insert into studcourse54 values('c1','1') insert into studcourse54 values('c1','1') * ERROR at line 1: ORA-00942: table or view does not exist SQL> / Enter value for rollno: 1 Enter value for cno: c1 old 1: insert into studcourse54 values('&rollno','&cno') new 1: insert into studcourse54 values('1','c1') insert into studcourse54 values('1','c1') * ERROR at line 1: ORA-00942: table or view does not exist SQL> create table stud_course54 2 ( 3 rollno varchar2(8)references student54, 4 cno varchar2(6)references course54, 5 primary key(rollno,cno) 6 ); create table stud_course54 * ERROR at line 1: ORA-00955: name is already used by an existing object

SQL> drop table stud_course54; Table dropped. SQL> 2 3 4 5 6 create table stud_course54 ( rollno varchar2(8)references student54, cno varchar2(6)references course54, primary key(rollno,cno) );

Table created. SQL> insert into stud_course54 values('&rollno','&cno'); Enter value for rollno: 1 Enter value for cno: c1 old 1: insert into stud_course54 values('&rollno','&cno') new 1: insert into stud_course54 values('1','c1') 1 row created. SQL> / Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> / Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> / Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> / Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> select * from stud_course54; ROLLNO CNO -------- -----1 c1 rollno: 5 cno: c5 into stud_course54 values('&rollno','&cno') into stud_course54 values('5','c5') rollno: 4 cno: c4 into stud_course54 values('&rollno','&cno') into stud_course54 values('4','c4') rollno: 3 cno: c3 into stud_course54 values('&rollno','&cno') into stud_course54 values('3','c3') rollno: 2 cno: c2 into stud_course54 values('&rollno','&cno') into stud_course54 values('2','c2')

2 3 4 5

c2 c3 c4 c5

SQL> insert into stud_course54 values('&rollno','&cno'); Enter value for rollno: 2 Enter value for cno: c5 old 1: insert into stud_course54 values('&rollno','&cno') new 1: insert into stud_course54 values('2','c5') 1 row created. SQL> / Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> / Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> / Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> / Enter value for Enter value for old 1: insert new 1: insert 1 row created. SQL> select * from stud_course54; ROLLNO -------1 2 3 4 5 2 4 5 2 4 CNO -----c1 c2 c3 c4 c5 c5 c3 c1 c3 c5 rollno: 4 cno: c5 into stud_course54 values('&rollno','&cno') into stud_course54 values('4','c5') rollno: 2 cno: c3 into stud_course54 values('&rollno','&cno') into stud_course54 values('2','c3') rollno: 5 cno: c1 into stud_course54 values('&rollno','&cno') into stud_course54 values('5','c1') rollno: 4 cno: c3 into stud_course54 values('&rollno','&cno') into stud_course54 values('4','c3')

10 rows selected. SQL> select count(sc.rollno) from student54 s,stud_course54 sc where s.rollno=sc .rollno and sname='r utuja'; COUNT(SC.ROLLNO) ---------------0 SQL> select s.*,cname from student54 s,stud_course54 sc,course54 c where s.rolln 0=sc.rollno and sc.c no=c.cno and cname='c++'; select s.*,cname from student54 s,stud_course54 sc,course54 c where s.rolln0=sc. rollno and sc.cno=c. * ERROR at line 1: ORA-00904: "S"."ROLLN0": invalid identifier SQL> select s.*,cname from student54 s,stud_course54 sc,course54 c where s.rolln o=sc.rollno and sc.c no=c.cno and cname='c++'; ROLLNO SNAME BIRTHDATE CNAME -------- ------------------------------ --------- -------------------2 sneha 02-MAY-92 c++ SQL> select * from course54 where coursefee=(select max(coursefee)from course54) ; CNO -----c1 c2 CNAME COURSEFEE DURATION -------------------- --------- --------c 5000 5 c++ 5000 4

SQL> select c.*,sname from student54 s,stud_course54 c where s.rollno=sc.rollno and c.cno=sc.cno ord er by c.cno; select c.*,sname from student54 s,stud_course54 c where s.rollno=sc.rollno and c .cno=sc.cno order by * ERROR at line 1: ORA-00904: "SC"."CNO": invalid identifier SQL> select c.*,sname from student54 s,stud_course54 sc,course54 cwhere s.rollno =sc.rollno and c.cno =sc.cno order by c.cno; select c.*,sname from student54 s,stud_course54 sc,course54 cwhere s.rollno=sc.r ollno and c.cno=sc.c * ERROR at line 1: ORA-00933: SQL command not properly ended SQL> select c.*,sname from student54 s,stud_course54 sc,course54 cwhere sc.rolln o=sc.rollno and c.cn o=sc.c

2 SQL> select c.*,sname from student54 s,stud_course54 c where sc.rollno=sc.rolln o and c.cno=sc.cno o rder by c.cno; select c.*,sname from student54 s,stud_course54 c where sc.rollno=sc.rollno and c.cno=sc.cno order * ERROR at line 1: ORA-00904: "SC"."CNO": invalid identifier SQL> select c.*,sname from student54 s,stud_course54 sc where sc.rollno=sc.rolln o and c.cno=sc.cno o rder by c.cno; select c.*,sname from student54 s,stud_course54 sc where sc.rollno=sc.rollno and c.cno=sc.cno order * ERROR at line 1: ORA-06552: PL/SQL: Statement ignored ORA-06553: PLS-225: subprogram or cursor 'C' reference is out of scope SQL> select c.*,sname from student54 s,stud_course54 sc,course54 c where s.rolln o=sc.rollno and c.cn o order by c.cno; select c.*,sname from student54 s,stud_course54 sc,course54 c where s.rollno=sc. rollno and c.cno ord * ERROR at line 1: ORA-00920: invalid relational operator SQL> select c.*,sname from student54 s,stud_course54 sc,course54 c where s.rolln o=sc.rollno and c.cn o order by c.cno; select c.*,sname from student54 s,stud_course54 sc,course54 c where s.rollno=sc. rollno and c.cno ord * ERROR at line 1: ORA-00920: invalid relational operator

S-ar putea să vă placă și