Oracle学习资料整理二

查询数据:
   单表查询: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/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值