查询数据:
单表查询:select col1,col2 from tableName;
多表查询,可采用直联、外联等方式进行查询:
直联查询:
只有在table1和table2中都存在,才能查询出结果集,换言之条件必须相等。
select table1.col1, table2.col2 from table1,table2 where table1.col1=table2.col1;
select table1.col1,table2.col2 from table1 join table2 on table1.col1=table2.col1;
外联查询:
一、将table1作为基表查询,将table1中的所有数据取出,如果没有关联到table2,那么以null值进行填充。
select table1.col1, table2.col2 from table1,table2 where table1.col1=table2.col1(+);
select table1.col1,table2.col2 from table1 left join table2 on table1.col1=table2.col1;
二、将table2作为基表查询,将table2中的所有数据取出,如果没有关联到table1,那么以null值进行填充。
select table1.col1, table2.col2 from table1,table2 where table1.col1(+)=table2.col1;
select table1.col1,table2.col2 from table1 right join table2 on table1.col1=table2.col1;
找回数据:
当使用delete删除时,可采用一下两种方式找回:
一、insert into tableName select * from tableName as of timestamp sysdate - 1/24/2 where colName= 999; --后面的select语句是查询回归段中据当前时间30之前的数据,具体回滚什么时候的数据自己根据实际情况确定。
二、另外一种方式不叫麻烦,就是利用闪回进行回滚:
1、查询SCN
select dbms_flashback.get_system_change_number from dual;
查询结果:10260843212274
2、查询
select count(*) from tableName as of scn 10260843205786;
查询结果:0
select count(*) from tableName as of scn 10260843205785;
查询结果:10
那么我们就可以确定SCN了。
3、回滚
insert into tableName select * from tableName as of scn 10260843205785;
当使用drop删除表时,可采用以下方式找回:
flashback table tableName to before drop;
单表查询:select col1,col2 from tableName;
多表查询,可采用直联、外联等方式进行查询:
直联查询:
只有在table1和table2中都存在,才能查询出结果集,换言之条件必须相等。
select table1.col1, table2.col2 from table1,table2 where table1.col1=table2.col1;
select table1.col1,table2.col2 from table1 join table2 on table1.col1=table2.col1;
外联查询:
一、将table1作为基表查询,将table1中的所有数据取出,如果没有关联到table2,那么以null值进行填充。
select table1.col1, table2.col2 from table1,table2 where table1.col1=table2.col1(+);
select table1.col1,table2.col2 from table1 left join table2 on table1.col1=table2.col1;
二、将table2作为基表查询,将table2中的所有数据取出,如果没有关联到table1,那么以null值进行填充。
select table1.col1, table2.col2 from table1,table2 where table1.col1(+)=table2.col1;
select table1.col1,table2.col2 from table1 right join table2 on table1.col1=table2.col1;
找回数据:
当使用delete删除时,可采用一下两种方式找回:
一、insert into tableName select * from tableName as of timestamp sysdate - 1/24/2 where colName= 999; --后面的select语句是查询回归段中据当前时间30之前的数据,具体回滚什么时候的数据自己根据实际情况确定。
二、另外一种方式不叫麻烦,就是利用闪回进行回滚:
1、查询SCN
select dbms_flashback.get_system_change_number from dual;
查询结果:10260843212274
2、查询
select count(*) from tableName as of scn 10260843205786;
查询结果:0
select count(*) from tableName as of scn 10260843205785;
查询结果:10
那么我们就可以确定SCN了。
3、回滚
insert into tableName select * from tableName as of scn 10260843205785;
当使用drop删除表时,可采用以下方式找回:
flashback table tableName to before drop;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25086534/viewspace-686901/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25086534/viewspace-686901/