时间:2021-07-01 10:21:17 帮助过:2人阅读
ALTER TABLE tablename ENABLE row movement ; flashback table tablename to timestamp to_timestamp(‘2012-09-13 13:00:00‘,‘yyyy-mm-dd hh24:mi:ss‘);
4.有一个类型为字符串的字段,要讲其值迁移到新系统里的数值类型字段中:
create or replace function isnum(v_in varchar2) return varchar is val_err exception; pragma exception_init(val_err, -6502) --char to num conv.error scrub_num number; begin scrub_num := to_number(v_in) return ‘Y‘; exception when val_err then return ‘N‘; end;
5.解决死锁问题:
(1).查看被锁的表 select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_objects b where b.object_id = a.object_id; (2).查看引起死锁的会话 select b.username,b.sid,b.serial#,logon_time from v$locked_object a,v$session b where a.session_id = b.sid order by b.logon_time; (3).杀掉死锁 alter system kill session ‘sid,serial#’;
6.查看当前连接用户正在运行的SQL语句:
select a.SID, a.USERNAME, b.SQL_TEXT from v$session a, v$sqltext_with_newlines b where a.SQL_ADDRESS = b.ADDRESS and a.SQL_HASH_VALUE = b.HASH_VALUE order by a.USERNAME, a.SID, b.piece
7.查询最消耗资源的实时语句:
oracle 11g中,可以通过查询V$SQL_MONITOR来监控SQL查询近乎实时的消耗资源 select * from ( select a.sid session_id,a.sql_id,a.status,a.cpu_time/1000000 cpu_sec,a.buffer_gets,a.disk_reads,b.sql_text sql_text from v$sql_monitor a,v$sql_b where a.sql_id=b.sql_id order by a.cpu_time desc) where rownum<=20;
本文出自 “彭泽0902” 博客,请务必保留此出处http://pengze0902.blog.51cto.com/7693836/1863181
Oracle常用的SQL方法总结
标签:oracle