Oracle常用SQL语句
递归查询部门
select * from table start with id= ? connect by prior id = parent_id;//查询id的子部门(包 括id自身) select * from table start with id= ? connect by prior parent_id= id;//查询id的父部门(包括id自身)
copy表
create table tableName as select * from tableName;//copy表
设置百分点
concat(to_char(count(distinct l.person_id) / count(l.person_id) * 100, ‘990.99‘), ‘%‘) baifen
for循环执行SQL语句
declare begin for i in 1..100 loop dbms_output.put_line(‘sql语句‘||i); end loop; end;
oracle查询已锁住的表
SELECT OBJECT_NAME, SESSION_ID SID, MACHINE, VS.MODULE, ‘ALTER SYSTEM KILL SESSION ‘‘‘ || SESSION_ID || ‘, ‘ || SERIAL#|| ‘‘‘; ‘ KILL_SESSION, VS.STATUS, VS.ACTION, SERIAL#, ORACLE_USERNAME, OS_USER_NAME FROM V$LOCKED_OBJECT VO, V$SESSION VS, ALL_OBJECTS AO WHERE VO.SESSION_ID = VS.SID AND AO.OBJECT_ID = VO.OBJECT_ID AND NVL(VS.ACTION, ‘ ‘) <> ‘Service Management ‘ ORDER BY OBJECT_NAME, MACHINE, VS.MODULE;
其中KILL_SESSION为对应解锁的SQL,需要具有权限才能执行
相关推荐
oraclemch 2020-11-06
Seandba 2020-08-16
dbasunny 2020-08-16
娜娜 2020-06-22
专注前端开发 2020-10-21
苏康申 2020-11-13
vitasfly 2020-11-12
liuyang000 2020-09-25
FellowYourHeart 2020-10-05
赵继业 2020-08-17
whyname 2020-08-16
拼命工作好好玩 2020-08-15
langyue 2020-08-15
写程序的赵童鞋 2020-08-03
Accpcjg 2020-08-02
tydldd 2020-07-30
好记忆也需烂 2020-07-28