查询表被锁住
--查询被锁的表 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; --查看是哪个session引起的 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; --杀掉对应进程即解锁 alter system kill session ‘1190,3103‘;
查询存储过程被锁住
--查询存储过程被锁 --查V$DB_OBJECT_CACHE SELECT * FROM V$DB_OBJECT_CACHE WHERE name=‘P_QUERY_BILL_LIST‘ AND LOCKS!=‘0‘; --按对象查出sid的值 select /*+ rule*/ SID from V$ACCESS WHERE object=‘P_QUERY_BILL_LIST‘; --查sid,serial# SELECT SID,SERIAL#,PADDR FROM V$SESSION WHERE SID in (‘1160‘); --杀掉对应进程即解锁 alter system kill session ‘1160,41565‘;
数据库数据被删掉,恢复删掉的数据
--数据库恢复 insert into sys_user_t value( select * from sys_user_t as of timestamp to_timestamp(‘2019-10-17 10:20:00‘,‘yyyy-mm-dd hh24:mi:ss‘) )
查询数据库对象(表,存储过程等)什么时候被修改过
-- 查询最后修改的对象 SELECT object_name,CREATED,LAST_DDL_TIME from user_objects order by last_ddl_time desc; SELECT object_name,CREATED,LAST_DDL_TIME from user_objects order by created desc;
oracle查询数据库编码
-- 编码 select userenv(‘language‘)from dual
设置本地环境变量
环境变量名:NLG_LANG
环境变量值:SIMPLIFIED CHINESE_CHINA.ZHS16GBK