详解Oracle解锁相关过程

数据库 Oracle
本文将介绍Oracle解锁相关过程,并由此帮助大家更好的理解Oracle中解锁的相关机制。

在这里我们将介绍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用户名更改操作四步走
责任编辑:彭凡 来源: CSDN
相关推荐

2009-12-03 09:24:11

VS开发人员新闻

2009-10-26 14:37:03

Oracle如何解锁用

2009-10-22 17:17:54

Oracle给用户解锁

2010-04-27 11:43:41

Oracle dele

2010-04-16 11:39:56

Oracle存储过程

2009-10-27 16:36:07

Oracle如何解锁

2010-08-13 14:08:45

Oracle

2010-04-29 14:06:40

Oracle SQL

2010-01-19 17:26:37

VB.NET创建过程

2010-04-14 14:14:42

Oracle用户解锁

2009-10-22 11:31:22

Oracle用户解锁命

2009-11-02 14:53:30

Oracle创建用户权

2011-08-18 17:05:16

Oracle数据库的服

2010-04-21 10:37:02

Oracle创建

2010-03-30 13:19:57

Oracle存储

2012-03-08 10:18:33

JavaOracle

2010-06-04 17:43:12

Hadoop集群搭建

2011-07-20 16:28:54

Oracle数据库shared pool

2015-10-28 15:35:33

Oracle策略

2010-04-30 14:22:43

Oracle通过
点赞
收藏

51CTO技术栈公众号