龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 数据库类 > Oracle 技术 >

详解Oracle解锁相关过程

时间:2011-04-12 23:18来源:未知 作者:admin 点击:
分享到:
在这里我们将介绍Oracle解锁的步骤,包括具体的代码以及操作,希望本文能为大家在Oracle数据库管理工作中,有所帮助。 from v$locked_objectt1,v$sessiont2 where t1.session_id=t2.sid order by t2.logon_

在这里我们将介绍Oracle解锁的步骤,包括具体的代码以及操作,希望本文能为大家在Oracle数据库管理工作中,有所帮助。

  1. from v$locked_object t1,v$session t2  
  2. where t1.session_id=t2.sid order by t2.logon_time; 

解锁

  1. --alter system kill session 'sid,serial'   
  2.  alter system kill session '146,21177'

锁表 --lock table tb_name in 模式

Null空值

  1. Null and false ->false 
  2. Null and true-> null 
  3. Null or false ->null 
  4. Null or true->true 

组函数忽略空值

空值排序时大于任何值,且不能被索引。

  1. Merge into 
  2. MERGE [hint] INTO [schema .] table [t_alias] USING [schema .]  
  3. table | view | subquery } [t_alias] ON ( condition )  
  4. WHEN MATCHED THEN merge_update_clause  
  5. WHEN NOT MATCHED THEN merge_insert_clause; 

例:

  1. merge into acct a  
  2. using subs b  
  3. on (a.msid = b.msid)  
  4. when MATCHED then 
  5.  update set a.areacode = b.areacode  
  6. when NOT MATCHED then 
  7. insert (msid, bill_month, areacode) values (b.msid, '200702', b.areacode) 

10g中增强一:条件操作 where

WHEN MATCHED THEN ...where ...

10g中增强二:删除操作

  1. An optional delete where clause can be used to clean up after a merge operation. Only those rows which match both the ON clause and the DELETE WHERE clause are deleted  
  2.  merge into acct a   
  3.  using subs b on (a.msid=b.msid)  
  4.  when MATCHED then 
  5. update set a.areacode=b.areacode  
  6.  delete where (b.ms_type!=0); 

其中满足 (b.ms_type!=0) 的将被deleted

With 语句

with语句只能用在select语句中,update和delete不支持

  1.  with summary as(  
  2. select dname, sum(sal) as dept_total  
  3. from ct_emp, ct_dept  
  4.  where ct_emp.deptno = ct_dept.deptno  
  5.  group by dname)  
  6. select dname, dept_total  
  7. from summary  
  8.  where dept_total > (select sum(dept_total) * 1 / 3 from summary);  

临时表temporary table

1、临时表需要先创建,不建议在运行时使用DDL语句创建

2、临时表可以看作是一张普通的物理表, 但它的数据是会话隔离的

区别之处:

l 向表中插入数据只在会话或事务期间存在

l 表中的数据只对插入数据的会话是可见的

l 可用ON COMMIT指导定数据是会话专用还是事务专用

  1. create global temporary tablename(column list)   
  2.  on commit preserve rows--提交保留数据会话临时表   
  3. on commit delete rows--提交删除数据 事务临时表  

oracle的临时表和sql server不一样,在使用完成以后,oracle临时表中的纪录可以被定义为自动删除(分session方式和transaction方式),而表结构不会被自动删除;sql server中的临时表在使用后会被完全删除。

建议:不得已的情况下(比较复杂的数据处理)才使用临时表,否则尽可能使用子查询代替或使用游标。

NVL,NVL2区别及NULLIF 的使用

| NVL(expr1, expr2):expr1为NULL,返回expr2;不为NULL,返回expr1。

| NVL2 (expr1, expr2, expr3) :xpr1不为NULL,返回expr2;为NULL,返回expr3。expr2和expr3类型不同的话,expr3会转换为expr2的类型

| NULLIF (expr1, expr2):相等返回NULL,不等返回expr1

  1. 详解Oracle如何解锁用户的方法
  2. 五分钟精通Oracle表空间
  3. 五种Oracle用户的授权与管理
  4. Oracle管理员手册:数据库管理工具
  5. Oracle用户名更改操作四步走
精彩图集

赞助商链接