You are on page 1of 20

SQL> select * from depart;

DCODE DNAME
---------- ------------------------------
cse computer science and engg.
it information technology.
ec electronics engg.
cv civil engg.
mech mechanical engg.
EEE electronics and elec engg.

6 rows selected.

SQL> select * from staffss;

SCODE SNAME DEPT FNAME


----- ------------------------- ---------- -------------------------
SALARY
--------------------
100 arun cse babu
1000

105 bala cse chandar


2000

110 kumar cse magesh


3000

SCODE SNAME DEPT FNAME


----- ------------------------- ---------- -------------------------
SALARY
--------------------
115 babu it hari
4000

120 easwar it kanni


5000

125 fazil it gopal


6000

SCODE SNAME DEPT FNAME


----- ------------------------- ---------- -------------------------
SALARY
--------------------
130 gopal ec ram
7000

135 hari ec babu


8000

140 jagan ec raj


9000

SCODE SNAME DEPT FNAME


----- ------------------------- ---------- -------------------------
SALARY
--------------------
145 kumar cv ram
10000

150 logesh cv babu


11000

155 nasar cv karthik


12000

SCODE SNAME DEPT FNAME


----- ------------------------- ---------- -------------------------
SALARY
--------------------
160 vijay mech kumar
13000

165 vikram mech raju


14000

170 vishwa mech rajesh


15000

15 rows selected.

SQL> select * from stu;

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
50 anand cse babu
9090456789

55 bala cse babu


9090678950

60 chandru cse deepak


9877896005

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
65 dana it damu
9898980007

70 easwar it ezhil
9845690089

75 fazil it farooq
9078967890

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
80 gopal ec guna
9023456789

85 hari ec harish
9879780679

90 parthi ec puraj
9077789660

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
95 ram cv raja
9088900112
100 raju cv kumar
9866789001

105 hari cv neyan


9778699056

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
110 zayed mech tim
9007655678

115 nasar mech narish


9866788907

120 baskar mech ravi


9765689078

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
5 uma cse gopi
9800978907

16 rows selected.

SQL> commit;

Commit complete.

SQL> select sum(salary)from staffss where dept='cse';

SUM(SALARY)
-----------
6000

SQL> select sum(salary)from staff group by(dept);


select sum(salary)from staff group by(dept)
*
ERROR at line 1:
ORA-00904: "SALARY": invalid identifier
SQL> ed;
Wrote file afiedt.buf

1* select sum(salary)from staffss group by(dept)


SQL> /

SUM(SALARY)
-----------
33000
6000
15000
24000
42000

SQL> select max(salary)from staffss;

MAX(SALARY)
--------------------
9000

SQL> select min(salary)from staffss;

MIN(SALARY)
--------------------
1000

SQL> select avg(salary)from staffss;

AVG(SALARY)
-----------
8000

SQL> select max(bpay)from staffss group by(dept);


select max(bpay)from staffss group by(dept)
*
ERROR at line 1:
ORA-00904: "BPAY": invalid identifier

SQL> ed;
Wrote file afiedt.buf

1* select max(salary)from staffss group by(dept)


SQL> /
MAX(SALARY)
--------------------
12000
3000
6000
9000
15000

SQL> select min(salary)from staffss group by(dept);

MIN(SALARY)
--------------------
10000
1000
4000
7000
13000

SQL> select avg(salary)from staffss group by(dept);

AVG(SALARY)
-----------
11000
2000
5000
8000
14000

SQL> select count(rollno)from staffss stu where dept='cse';


select count(rollno)from staffss stu where dept='cse'
*
ERROR at line 1:
ORA-00904: "ROLLNO": invalid identifier

SQL> ed;
Wrote file afiedt.buf

1* select count(rollno)from stu where dept='cse'


SQL> /

COUNT(ROLLNO)
-------------
4
SQL> select count(mobile)from stu;

COUNT(MOBILE)
-------------
16

SQL> select * from stu order by(name);


select * from stu order by(name)
*
ERROR at line 1:
ORA-00904: "NAME": invalid identifier

SQL> ed;
Wrote file afiedt.buf

1* select * from stu order by(sname)


SQL> /

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
50 anand cse babu
9090456789

55 bala cse babu


9090678950

120 baskar mech ravi


9765689078

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
60 chandru cse deepak
9877896005

65 dana it damu
9898980007

70 easwar it ezhil
9845690089
ROLLNO SNAME DEPT FNAME
---------- ------------------------- ---------- -------------------------
MOBILE
----------
75 fazil it farooq
9078967890

80 gopal ec guna
9023456789

85 hari ec harish
9879780679

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
105 hari cv neyan
9778699056

115 nasar mech narish


9866788907

90 parthi ec puraj
9077789660

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
100 raju cv kumar
9866789001

95 ram cv raja
9088900112

5 uma cse gopi


9800978907

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
110 zayed mech tim
9007655678

16 rows selected.

SQL> commit;

Commit complete.

SQL> create view tccsesel as select rollno,sname,dept from stu where dept='cse';

View created.

SQL> select * from tccsesel;

ROLLNO SNAME DEPT


---------- ------------------------- ----------
50 anand cse
55 bala cse
60 chandru cse

SQL> create view tccsesel as select rollno,sname from stu where dept='cse';
create view tccsesel as select rollno,sname from stu where dept='cse'
*
ERROR at line 1:
ORA-00955: name is already used by an existing object

SQL> ed;
Wrote file afiedt.buf

1* create view tcs as select rollno,sname,from stu where dept='cse'


SQL> /
create view tcs as select rollno,sname,from stu where dept='cse'
*
ERROR at line 1:
ORA-00936: missing expression

SQL> ed;
Wrote file afiedt.buf

1* create view tcs as select rollno,sname,from stu where dept='cse;'


SQL> /
create view tcs as select rollno,sname,from stu where dept='cse;'
*
ERROR at line 1:
ORA-00936: missing expression

SQL> ed;
Wrote file afiedt.buf

1* create view tcs as select rollno,sname,from stu where dept='cse';


SQL> /
create view tcs as select rollno,sname,from stu where dept='cse';
*
ERROR at line 1:
ORA-00936: missing expression

SQL> ed;
Wrote file afiedt.buf

1* create view tcs as select rollno,sname from stu where dept='cse';


SQL> /
create view tcs as select rollno,sname from stu where dept='cse';
*
ERROR at line 1:
ORA-00911: invalid character

SQL> create view tcs as select rollno,sname from stu;

View created.

SQL> select * from tccse;

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
50 anand cse babu
9090456789

55 bala cse babu


9090678950

60 chandru cse deepak


9877896005

SQL> create view tcsdel as select rollno,sname from stu;

View created.

SQL> select * from tab;

TNAME TABTYPE CLUSTERID


------------------------------ ------- ----------
STAF TABLE
STA TABLE
STAFFF TABLE
STUDENT TABLE
DEPART TABLE
STAFFSS TABLE
STU TABLE
TCCSE VIEW
TCCSESEL VIEW
TCS VIEW
TCSDEL VIEW

6 rows selected.

SQL> drop view tcsdel;

View dropped.

SQL> select * from tab;

TNAME TABTYPE CLUSTERID


------------------------------ ------- ----------
STAF TABLE
STA TABLE
STAFFF TABLE
STUDENT TABLE
DEPART TABLE
STAFFSS TABLE
STU TABLE
TCCSE VIEW
TCCSESEL VIEW
TCS VIEW
5 rows selected.

SQL> create view join view as select rollno,a.sname,dname,counid,c.sname as staffname


from student a
,depa;
create view join view as select rollno,a.sname,dname,counid,c.sname as staffname from
student a,depa
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> create view join view as select rollno,a.sname,dname,counid,c.sname as staffname


from stu a,dep
art b,staffss c where a.depart=b.dcode and a.counid=c.sode;
create view join view as select rollno,a.sname,dname,counid,c.sname as staffname from
stu a,depart b
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> ed;
Wrote file afiedt.buf

1* create view joinview as select rollno,a.sname,dname,counid,c.sname as staffname


from stu a,depa
SQL> /
create view joinview as select rollno,a.sname,dname,counid,c.sname as staffname from
stu a,depart b,

ERROR at line 1:
ORA-00904: "C"."SODE": invalid identifier

SQL> commit;

Commit complete.

SQL> ed;
Wrote file afiedt.buf

1* commit
SQL> create view join view as select rollno,a.sname,dname,counid,c.sname as staffname
from stu a,dep
art b,staffss c where a.depart=b.dcode and a.counid=c.scode;
create view join view as select rollno,a.sname,dname,counid,c.sname as staffname from
stu a,depart b
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> ed;
Wrote file afiedt.buf

1* create view joinview as select rollno,a.sname,dname,counid,c.sname as staffname


from stu a,depa
SQL> /
create view joinview as select rollno,a.sname,dname,counid,c.sname as staffname from
stu a,depart b,

ERROR at line 1:
ORA-00904: "A"."COUNID": invalid identifier

SQL> ed;
Wrote file afiedt.buf

1* create view joinview as select rollno,a.sname,dname,counid,c.sname as staffname


from stu a,depa
SQL> ed;
Wrote file afiedt.buf

1* create view joinview as select rollno,a.sname,dname,counid,c.sname as staffname


from stu a,depa
SQL> /
create view joinview as select rollno,a.sname,dname,counid,c.sname as staffname from
stu a,depart b,

ERROR at line 1:
ORA-00904: "A"."COUNID": invalid identifier

SQL> ed;
Wrote file afiedt.buf

1* create view joinview as select rollno,a.sname,dname,counid,c.sname as staffname


from stu a,depa
SQL> /
create view joinview as select rollno,a.sname,dname,counid,c.sname as staffname from
stu a,depart b,
ERROR at line 1:
ORA-00904: "C"."COUNID": invalid identifier

SQL> create view recdept as select dcode from depart;

View created.

SQL> create view recdeptall as select * from depart;

View created.

SQL> insert into recdepartall values('EEE','electronics and elec engg.');


insert into recdepartall values('EEE','electronics and elec engg.')
*
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> ed;
Wrote file afiedt.buf

1* insert into recdeptall values('EEE','electronics and elec engg.')


SQL> /

1 row created.

SQL> select * from depart;

DCODE DNAME
---------- ------------------------------
cse computer science and engg.
it information technology.
ec electronics engg.
cv civil engg.
mech mechanical engg.
EEE electronics and elec engg.

6 rows selected.

SQL> select * from recdeptall;

DCODE DNAME
---------- ------------------------------
cse computer science and engg.
it information technology.
ec electronics engg.
cv civil engg.
mech mechanical engg.
EEE electronics and elec engg.

6 rows selected.

SQL> create table voter(vid number(5) primary key,vname varchar2(20) not null,age
number(3)check(age
>=18),mobile varchar2(10);
create table voter(vid number(5) primary key,vname varchar2(20) not null,age
number(3)check(age>=18)

ERROR at line 1:
ORA-00907: missing right parenthesis

SQL> ed;
Wrote file afiedt.buf

1* create table voter(vid number(5) primary key,vname varchar2(20) not null,age


number(3)check(age
SQL> /

Table created.

SQL> create view voterview as select vid,vname from voter;

View created.

SQL> insert into voter view values(1,'arul s');


insert into voter view values(1,'arul s')
*
ERROR at line 1:
ORA-00926: missing VALUES keyword

SQL> ed;
Wrote file afiedt.buf

1* insert into voterview values(1,'arul s')


SQL> /

1 row created.
SQL> select * from voter;

VID VNAME AGE MOBILE


---------- -------------------- ---------- ----------
1 arul s

SQL> create view voterview vidas select vid,mobile from voter;


create view voterview vidas select vid,mobile from voter
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> ed;
Wrote file afiedt.buf

1* create view voterview vid as select vid,mobile from voter


SQL> /
create view voterview vid as select vid,mobile from voter
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> ed;
Wrote file afiedt.buf

1* create view voterviewvid as select vid,mobile from voter


SQL> /

View created.

SQL> select * from voter;

VID VNAME AGE MOBILE


---------- -------------------- ---------- ----------
1 arul s

SQL> create view voterairtel values as select * from voter where mobile like '9894%;
create view voterairtel values as select * from voter where mobile like '9894%
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> ed;
Wrote file afiedt.buf

1* create view voterairtel values as select * from voter where mobile like '9894009009';
SQL> /
create view voterairtel values as select * from voter where mobile like '9894009009';
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> ed;
Wrote file afiedt.buf

1* create view voterairtel values as select * from voter where mobile like
'9894009009%';
SQL> /
create view voterairtel values as select * from voter where mobile like '9894009009%';
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> ed;
Wrote file afiedt.buf

1* create view voterairtel values as select * from voter


SQL> /
create view voterairtel values as select * from voter
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> ed;
Wrote file afiedt.buf

1* create view voterairtel values as select * from voter;


SQL> /
create view voterairtel values as select * from voter;
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> ed;
Wrote file afiedt.buf
1* create view voterairtel values as select * from voter where mobile like '9566789089';
SQL> /
create view voterairtel values as select * from voter where mobile like '9566789089';
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> ed;
Wrote file afiedt.buf

1* create view voterairtel values as select * from voter where mobile like '9844%'with
check optio
SQL> /
create view voterairtel values as select * from voter where mobile like '9844%'with check
option;
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> ed;
Wrote file afiedt.buf

1* create view voterairtel values as select * from voter where mobile like '9844%' with
check opti
SQL> /
create view voterairtel values as select * from voter where mobile like '9844%' with
check option;
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> ed;
Wrote file afiedt.buf

1* create view voterairtel values as select * from voter where mobile like
'9844567890%' with chec
SQL> /
create view voterairtel values as select * from voter where mobile like '9844567890%'
with check opt
*
ERROR at line 1:
ORA-00905: missing keyword
SQL> ed;
Wrote file afiedt.buf

1* create view voterairtel values as select * from voter where mobile like '9844567890'
with check
SQL> /
create view voterairtel values as select * from voter where mobile like '9844567890' with
check opti
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> create view voteratcheck as select * from voter where mobile like '9894%'with
check option;

View created.

SQL> insert into voteratcheck values(2,'dhana',28,'9088900789');


insert into voteratcheck values(2,'dhana',28,'9088900789')
*
ERROR at line 1:
ORA-01402: view WITH CHECK OPTION where-clause violation

SQL> ed;
Wrote file afiedt.buf

1* insert into voteratcheck values(2,'dhana','9088900789')


SQL> /
insert into voteratcheck values(2,'dhana','9088900789')
*
ERROR at line 1:
ORA-00947: not enough values

SQL> create view vvtccse as select rollno,sname from tccse;

View created.

SQL> select * from tccse;

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
50 anand cse babu
9090456789

55 bala cse babu


9090678950

60 chandru cse deepak


9877896005

SQL> insert into stu values('05','uma','cse','gopi','9800978907');

1 row created.

SQL> select * from tccse;

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
50 anand cse babu
9090456789

55 bala cse babu


9090678950

60 chandru cse deepak


9877896005

ROLLNO SNAME DEPT FNAME


---------- ------------------------- ---------- -------------------------
MOBILE
----------
5 uma cse gopi
9800978907

SQL> commit;

Commit complete.

SQL>

You might also like