Enter user-name: mti547
Enter password:
Connected to:
Oracle Database 10g Express Edition Release [Link].0 - Production
SQL> create table student(id int,name varchar(10),branch varchar(10),college varchar(10));
Table created.
SQL> desc student
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER(38)
NAME VARCHAR2(10)
BRANCH VARCHAR2(10)
COLLEGE VARCHAR2(10)
SQL> insert into student values(547,'anil_kumar','cse','mtieat');
1 row created.
SQL> insert into student values(54,'ravi','ece','mtieat');
1 row created.
SQL> insert into student values(55,'manju','it','mtieat');
1 row created.
SQL> insert into student values(56,'veera','ai_ds','mtieat');
1 row created.
SQL> insert into student values(57,'ramu','eee','mtieat');
1 row created.
SQL> insert into student values(58,'raj','civil','mtieat');
1 row created.
SQL> select *from student;
ID NAME BRANCH COLLEGE
---------- ---------- ---------- ----------
547 anil_kumar cse mtieat
54 ravi ece mtieat
55 manju it mtieat
56 veera ai_ds mtieat
57 ramu eee mtieat
58 raj civil mtieat
6 rows selected.
SQL> create table employe(id int,name varchar(10),location varchar(10), salary int);
Table created.
SQL> insert into employe values(1000,'anil','chittoor',100000);
1 row created.
SQL> insert into employe values(1001,'kumar','tirupati',50000);
1 row created.
SQL> insert into employe values(1002,'raju','kurnol',55000);
1 row created.
SQL> insert into employe values(1003,'shaike','kadapa',75000);
1 row created.
SQL> insert into employe values(1004,'madhan','lucknow',65000);
1 row created.
SQL> select *from employe;
ID NAME LOCATION SALARY
---------- ---------- ---------- ----------
1000 anil chittoor 100000
1001 kumar tirupati 50000
1002 raju kurnol 55000
1003 shaike kadapa 75000
1004 madhan lucknow 65000
SQL> commit;
Commit complete.
SQL> rollback;
Rollback complete.
SQL> select min(salary) from employe;
MIN(SALARY)
-----------
50000
SQL> select mia(salary) from employe;
select mia(salary) from employe
ERROR at line 1:
ORA-00904: "MIA": invalid identifier
SQL> select mix(salary) from employe;
select mix(salary) from employe
ERROR at line 1:
ORA-00904: "MIX": invalid identifier
SQL> select max(salary) from employe;
MAX(SALARY)
-----------
100000
SQL> select count(salary) from employe;
COUNT(SALARY)
-------------
SQL> select sum(salary) from employe;
SUM(SALARY)
-----------
345000
SQL> select avg(salary) from employe;
AVG(SALARY)
-----------
69000
SQL> select id from student union select id from employe;
ID
----------
54
55
56
57
58
547
1000
1001
1002
1003
1004
11 rows selected.
SQL> select id from student unionall select id from employe;
select id from student unionall select id from employe
ERROR at line 1:
ORA-00933: SQL command not properly ended
SQL> select id from student unionAll select id from employe;
select id from student unionAll select id from employe
ERROR at line 1:
ORA-00933: SQL command not properly ended
SQL> select id from student unionALL select id from employe;
select id from student unionALL select id from employe
*
ERROR at line 1:
ORA-00933: SQL command not properly ended
SQL> select id from student intersect select id from employe;
no rows selected
SQL> select id from student UNION ALL select id from employe;
ID
----------
547
54
55
56
57
58
1000
1001
1002
1003
1004
11 rows selected.
SQL> select id from student union all select id from employe;
ID
----------
547
54
55
56
57
58
1000
1001
1002
1003
1004
11 rows selected.
SQL> alter student add branch varchar(10);
alter student add branch varchar(10)
ERROR at line 1:
ORA-00940: invalid ALTER command
SQL> alter table student add branch varchar(10);
alter table student add branch varchar(10)
ERROR at line 1:
ORA-01430: column being added already exists in table
SQL> alter table student add age varchar(10);
Table altered.
SQL> update student set age=20 where id in(47,54,55);
2 rows updated.
SQL> select *from student;
ID NAME BRANCH COLLEGE AGE
---------- ---------- ---------- ---------- ----------
547 anil_kumar cse mtieat
54 ravi ece mtieat 20
55 manju it mtieat 20
56 veera ai_ds mtieat
57 ramu eee mtieat
58 raj civil mtieat
6 rows selected.
SQL> update student set age=20 where id in(47);
0 rows updated.
SQL> update student set age=20 where id in(547);
1 row updated.
SQL> update student set age=20 where id not in(57,58);
4 rows updated.
SQL> select *from student;
ID NAME BRANCH COLLEGE AGE
---------- ---------- ---------- ---------- ----------
547 anil_kumar cse mtieat 20
54 ravi ece mtieat 20
55 manju it mtieat 20
56 veera ai_ds mtieat 20
57 ramu eee mtieat
58 raj civil mtieat
6 rows selected.
SQL> update student set age=18 where id in(547);
1 row updated.
SQL> update student set age=19 where id in(54);
1 row updated.
SQL> update student set age=21 where id in(58);
1 row updated.
SQL> select *from student;
ID NAME BRANCH COLLEGE AGE
---------- ---------- ---------- ---------- ----------
547 anil_kumar cse mtieat 18
54 ravi ece mtieat 19
55 manju it mtieat 20
56 veera ai_ds mtieat 20
57 ramu eee mtieat
58 raj civil mtieat 21
6 rows selected.
SQL> select *from student where branch in('it','cse');
ID NAME BRANCH COLLEGE AGE
---------- ---------- ---------- ---------- ----------
547 anil_kumar cse mtieat 18
55 manju it mtieat 20
SQL> select *from student where branch not in('it','cse');
ID NAME BRANCH COLLEGE AGE
---------- ---------- ---------- ---------- ----------
54 ravi ece mtieat 19
56 veera ai_ds mtieat 20
57 ramu eee mtieat
58 raj civil mtieat 21
SQL> select name from student where name=any(select name from student);
NAME
----------
anil_kumar
ravi
manju
veera
ramu
raj
6 rows selected.
SQL> select name from student where ;
select name from student where
ERROR at line 1:
ORA-00936: missing expression
SQL> select name from student;
NAME
----------
anil_kumar
ravi
manju
veera
ramu
raj
6 rows selected.
SQL> select name from student where name='raj';
NAME
----------
raj
SQL> select branch from student where name='raj';
BRANCH
----------
civil
SQL> select branch from student where name=any();
select branch from student where name=any()
ERROR at line 1:
ORA-00936: missing expression
SQL> select branch from student where name=any;
select branch from student where name=any
*
ERROR at line 1:
ORA-00936: missing expression
SQL> select branch from student where name=any('anil_kumar');
BRANCH
----------
cse
SQL> create table my(age int,name varchar(10));
Table created.
SQL> insert into my values(18,'anil');
1 row created.
SQL> insert into my values(19,'kumar');
1 row created.
SQL> insert into my values(20,'vijay');
1 row created.
SQL> truncate table my;
Table truncated.
SQL> select *from my;
no rows selected
SQL> desc my;
Name Null? Type
----------------------------------------- -------- ----------------------------
AGE NUMBER(38)
NAME VARCHAR2(10)
SQL> drop table my;
Table dropped.
SQL> desc my;
ERROR:
ORA-04043: object my does not exist
SQL> select count(name) from employe group by id;
COUNT(NAME)
-----------
SQL> select count(name) from employe group by salary;
COUNT(NAME)
-----------
SQL> update employe set salary=65000 where id in(547);
0 rows updated.
SQL> update employe set salary=65000 where id in(54);
0 rows updated.
SQL> selct *from employe;
SP2-0734: unknown command beginning "selct *fro..." - rest of line ignored.
SQL> select *from employe;
ID NAME LOCATION SALARY
---------- ---------- ---------- ----------
1000 anil chittoor 100000
1001 kumar tirupati 50000
1002 raju kurnol 55000
1003 shaike kadapa 75000
1004 madhan lucknow 65000
SQL> update employe set salary=65000 where id in(1000);
1 row updated.
SQL> select *from employe;
ID NAME LOCATION SALARY
---------- ---------- ---------- ----------
1000 anil chittoor 65000
1001 kumar tirupati 50000
1002 raju kurnol 55000
1003 shaike kadapa 75000
1004 madhan lucknow 65000
SQL> update employe set salary=100000 where id in(1000);
1 row updated.
SQL> select *from employe;
ID NAME LOCATION SALARY
---------- ---------- ---------- ----------
1000 anil chittoor 100000
1001 kumar tirupati 50000
1002 raju kurnol 55000
1003 shaike kadapa 75000
1004 madhan lucknow 65000
SQL> select count(name) from employe group by name;
COUNT(NAME)
-----------
1
1
SQL> insert into employe values(1000,'ram','mysore',30000);
1 row created.
SQL> select count(name) from employe group by name;
COUNT(NAME)
-----------
6 rows selected.
SQL> select count(name) from employe group by id;
COUNT(NAME)
-----------
2
1
SQL> select count(id) from employe group by id;
COUNT(ID)
----------
SQL> select count(id) from employe group by name;
COUNT(ID)
----------
1
6 rows selected.
SQL> select count(id) from employe group by id;
COUNT(ID)
----------