create table transactiondemo
(
col1 number(2),
col2 char(4)
);
insert into transactiondemo values
(1,'a');
insert into transactiondemo values
(2,'b');
select * from transactiondemo;
COL1 COL2
---------- ----
1 a
2 b
rollback;
Rollback complete.
select * from transactiondemo;
no rows selected
insert into transactiondemo values
(1,'a');
SQL> savepoint save1;
Savepoint created.
insert into transactiondemo values
(2,'b');
SQL> select * from transactiondemo;
COL1 COL2
---------- ----
1 a
2 b
rollback to save1;
select * from transactiondemo;
COL1 COL2
---------- ----
1 a
SQL> rename transactiondemo to tdemo;
Table renamed.
SQL> select * from tdemo;
COL1 COL2
---------- ----
1 a
SQL> select * from transactiondemo;
select * from transactiondemo
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select * from cedetails;
EID FNAME LNAME HIREDATE SALARY JOB_ID DEPT COMMISSION_PCT DAILYWAG
---- --------------- -------------------- --------- ---------- -------- ---- -------------- --------
e1 sai kiran 23-FEB-09 23000 IT_PROG D01
e2 jai krishnan 24-APR-09 27000 ST_CLERK D01
e3 ashok kumar 21-APR-09 27000 SAEXE D02 .1
e4 Geethu Mohan 14-APR-09 27000 SA_MAN D02 .3
e5 Arafat Aboobacker 21-APR-09 27000 SA_REP D03 .2
SQL> alter table cedetails set unused (hiredate);
Table altered.
SQL> select * from cedetails;
EID FNAME LNAME SALARY JOB_ID DEPT COMMISSION_PCT DAILYWAGES
---- --------------- -------------------- ---------- -------- ---- -------------- ----------
e1 sai kiran 23000 IT_PROG D01
e2 jai krishnan 27000 ST_CLERK D01
e3 ashok kumar 27000 SAEXE D02 .1
e4 Geethu Mohan 27000 SA_MAN D02 .3
e5 Arafat Aboobacker 27000 SA_REP D03 .2
SQL> alter table cedetails set unused (job_id);
Table altered.
SQL> select * from cedetails;
EID FNAME LNAME SALARY DEPT COMMISSION_PCT DAILYWAGES
---- --------------- -------------------- ---------- ---- -------------- ----------
e1 sai kiran 23000 D01
e2 jai krishnan 27000 D01
e3 ashok kumar 27000 D02 .1
e4 Geethu Mohan 27000 D02 .3
e5 Arafat Aboobacker 27000 D03 .2
SQL> describe cedetails;
Name
---------------------------------------------------------------------------------------------------
EID
FNAME
LNAME
SALARY
DEPTID
COMMISSION_PCT
DAILYWAGES
SQL>
SQL> create table copyedetails as
select * from edetails where 0 >1;
Table created.
SQL> select * from copyedetails;
no rows selected
insert into copyedetails select * from edetails;
SQL> insert into copyedetails select * from edetails;
5 rows created.
SQL> select * from copyedetails;
EID FNAME LNAME HIREDATE SALARY JOB_ID DEPT COMMISSION_PCT DAILYWAG
---- --------------- -------------------- --------- ---------- -------- ---- -------------- --------
e1 sai kiran 23-FEB-09 23000 IT_PROG D01
e2 jai krishnan 24-APR-09 27000 ST_CLERK D01
e3 ashok kumar 21-APR-09 27000 SAEXE D02 .1
e4 Geethu Mohan 14-APR-09 27000 SA_MAN D02 .3
e5 Arafat Aboobacker 21-APR-09 27000 SA_REP D03 .2
SQL>
SQL> select fname ,salary from edetails e where salary >= (select avg(salary) from edetails ed where
ed.deptid=e.deptid);
FNAME SALARY
--------------- ----------
jai 27000
ashok 27000
Geethu 27000
Arafat 27000
Urmilla 28000
Sajesh 29000
Manu 29000
(
col1 number(2),
col2 char(4)
);
insert into transactiondemo values
(1,'a');
insert into transactiondemo values
(2,'b');
select * from transactiondemo;
COL1 COL2
---------- ----
1 a
2 b
rollback;
Rollback complete.
select * from transactiondemo;
no rows selected
insert into transactiondemo values
(1,'a');
SQL> savepoint save1;
Savepoint created.
insert into transactiondemo values
(2,'b');
SQL> select * from transactiondemo;
COL1 COL2
---------- ----
1 a
2 b
rollback to save1;
select * from transactiondemo;
COL1 COL2
---------- ----
1 a
SQL> rename transactiondemo to tdemo;
Table renamed.
SQL> select * from tdemo;
COL1 COL2
---------- ----
1 a
SQL> select * from transactiondemo;
select * from transactiondemo
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select * from cedetails;
EID FNAME LNAME HIREDATE SALARY JOB_ID DEPT COMMISSION_PCT DAILYWAG
---- --------------- -------------------- --------- ---------- -------- ---- -------------- --------
e1 sai kiran 23-FEB-09 23000 IT_PROG D01
e2 jai krishnan 24-APR-09 27000 ST_CLERK D01
e3 ashok kumar 21-APR-09 27000 SAEXE D02 .1
e4 Geethu Mohan 14-APR-09 27000 SA_MAN D02 .3
e5 Arafat Aboobacker 21-APR-09 27000 SA_REP D03 .2
SQL> alter table cedetails set unused (hiredate);
Table altered.
SQL> select * from cedetails;
EID FNAME LNAME SALARY JOB_ID DEPT COMMISSION_PCT DAILYWAGES
---- --------------- -------------------- ---------- -------- ---- -------------- ----------
e1 sai kiran 23000 IT_PROG D01
e2 jai krishnan 27000 ST_CLERK D01
e3 ashok kumar 27000 SAEXE D02 .1
e4 Geethu Mohan 27000 SA_MAN D02 .3
e5 Arafat Aboobacker 27000 SA_REP D03 .2
SQL> alter table cedetails set unused (job_id);
Table altered.
SQL> select * from cedetails;
EID FNAME LNAME SALARY DEPT COMMISSION_PCT DAILYWAGES
---- --------------- -------------------- ---------- ---- -------------- ----------
e1 sai kiran 23000 D01
e2 jai krishnan 27000 D01
e3 ashok kumar 27000 D02 .1
e4 Geethu Mohan 27000 D02 .3
e5 Arafat Aboobacker 27000 D03 .2
SQL> describe cedetails;
Name
---------------------------------------------------------------------------------------------------
EID
FNAME
LNAME
SALARY
DEPTID
COMMISSION_PCT
DAILYWAGES
SQL>
SQL> create table copyedetails as
select * from edetails where 0 >1;
Table created.
SQL> select * from copyedetails;
no rows selected
insert into copyedetails select * from edetails;
SQL> insert into copyedetails select * from edetails;
5 rows created.
SQL> select * from copyedetails;
EID FNAME LNAME HIREDATE SALARY JOB_ID DEPT COMMISSION_PCT DAILYWAG
---- --------------- -------------------- --------- ---------- -------- ---- -------------- --------
e1 sai kiran 23-FEB-09 23000 IT_PROG D01
e2 jai krishnan 24-APR-09 27000 ST_CLERK D01
e3 ashok kumar 21-APR-09 27000 SAEXE D02 .1
e4 Geethu Mohan 14-APR-09 27000 SA_MAN D02 .3
e5 Arafat Aboobacker 21-APR-09 27000 SA_REP D03 .2
SQL>
SQL> select fname ,salary from edetails e where salary >= (select avg(salary) from edetails ed where
ed.deptid=e.deptid);
FNAME SALARY
--------------- ----------
jai 27000
ashok 27000
Geethu 27000
Arafat 27000
Urmilla 28000
Sajesh 29000
Manu 29000
No comments:
Post a Comment
Thanks for your valuable comments