加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ORACLE SQL 小结

发布时间:2020-12-12 15:29:24 所属栏目:百科 来源:网络整理
导读:执行顺序 参考:http://www.tuicool.com/articles/fERNv2 1、数据库备份 记住加个owner,高效 ?导出sqlexp abc/222221@orcl file=E:wtkjjd.dmp owner = maeipuser导入sqlimp system/123456@orcl file=d:daochu.dmp full=y ignore=y指定导出用户,导入用户i

执行顺序

参考:http://www.tuicool.com/articles/fERNv2

1、数据库备份

记住加个owner,高效

?导出sql
exp abc/222221@orcl file=E:wtkjjd.dmp owner = maeipuser

导入sql
imp system/123456@orcl file=d:daochu.dmp full=y ignore=y
指定导出用户,导入用户
imp scott/sss@orcl  fromuser=JSUSER touser=scott file=d:Desktop221.dmp ignore=y

?

2、in、any、all

子查询中的in,any,all

   select * from orderinfo where userid in (select userid from userinfo where username = 'abcd')与sqlserver一样

   select * from orderinfo where userid > any (select userid from userinfo where username = 'abcd')

   只要userid大于任何一个子查询中的userid则返回数据行

   select * from orderinfo where userid > all(select userid from userinfo where username ='abcd')

   userid必须大于子查询中所有的userid才能返回数据行

3、自然连接natural join

 select o.orderid,u.userid from orderinfo o natural join userinfo u where o.orderid = 1

 oracle把两个表中名称相同的列自动连接

4、case when 使用

CASE 
     WHEN sex = '1' THEN '男'
     WHEN sex = '2' THEN '女'
     ELSE '其他' END

5、decode函数

decode(性别,男,1,0)

decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值)

IF 条件=值1 THEN
    RETURN(翻译值1)
ELSIF 条件=值2 THEN
    RETURN(翻译值2)
    ......

6、误删恢复sql

insert into sh_cases select * from sh_cases AS OF TIMESTAMP  (SYSTIMESTAMP - INTERVAL '100' MINUTE);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读