《Oralce9i参考手册》部分学习随笔

1.临时表的建立
 Create global temporary table tableName(
  name nvarchar(20),id int
 )on commit [delete/preserve] rows;
on commit delete rows就是事务处理完了就自动删除表
on commit preserve rows就是会话完了就自动删除表
可以通过查询user_tables表 来查看临时表的信息 其中duration列的信息为sys$session 的

2.遍历树查询
 select employee,manager from AdminUser start with employee='administrator'
 connect by manager =  prior employee
start with的意思是 以employee的值为administrator 作为根节点
connect by的意思是 告诉sql查找下一行,其中manager的值和前面行的employee值相等

3.并合数据源
 merge into table1 t1
 using(select id,name from table2 t2)
 on t1.id=t2.id
 when matched then
  update set t1.name=t2.name
 when not matched then
  insert(t1.id,t1.name)
  values(t2.id,t2.name);
第1句就是 命名目标表table1 给出别名t1
  2       指定的更新数据源
  3       匹配条件
  4,5     相匹配的话则更新name列
  6,7,8   不相匹配的 就插入t2的记录

4.从查询中建立表
 create table myTable1 [nologging] as select * from myTable2;
 等同于Mssql的
 select * into myTable2 from myTable1;

 注意:如果oracle表中其中一列为LONG类型的话,则Create table ... as select ...不起作用
 使用nologging选项不产生重做日志 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值