鏌ョ湅褰撳墠鐢ㄦ埛鐨勮鑹?br />
SQL>select * from user_role_privs;
鏌ョ湅褰撳墠鐢ㄦ埛鐨勭郴緇熸潈闄愬拰琛ㄧ駭鏉冮檺
SQL>select * from user_sys_privs;
SQL>select * from user_tab_privs;
浜屻佽〃
鏌ョ湅鐢ㄦ埛涓嬫墍鏈夌殑琛?br />
SQL>select * from user_tables;
鏌ョ湅鍚嶇О鍖呭惈log瀛楃鐨勮〃
SQL>select object_name,object_id from user_objects
where instr(object_name,LOG)>0;
鏌ョ湅鏌愯〃鐨勫垱寤烘椂闂?
SQL>select object_name,created from user_objects where object_name=upper(&table_name);
鏌ョ湅鏌愯〃鐨勫ぇ灝?br />
SQL>select sum(bytes)/(1024*1024) as "size(M)" from user_segments
where segment_name=upper(&table_name);
鏌ョ湅鏀懼湪ORACLE鐨勫唴瀛樺尯閲岀殑琛?
SQL>select table_name,cache from user_tables where instr(cache,Y)>0;
涓夈佺儲寮?br />
鏌ョ湅绱㈠紩涓暟鍜岀被鍒?br />
SQL>select index_name,index_type,table_name from user_indexes order by table_name;
鏌ョ湅绱㈠紩琚儲寮曠殑瀛楁
SQL>select * from user_ind_columns where index_name=upper(&index_name);
鏌ョ湅绱㈠紩鐨勫ぇ灝?br />
SQL>select sum(bytes)/(1024*1024) as "size(M)" from user_segments
where segment_name=upper(&index_name);
鍥涖佸簭鍒楀彿
鏌ョ湅搴忓垪鍙鳳紝last_number鏄綋鍓嶅?br />
SQL>select * from user_sequences;
浜斻佽鍥?br />
鏌ョ湅瑙嗗浘鐨勫悕縐?br />
SQL>select view_name from user_views;
鏌ョ湅鍒涘緩瑙嗗浘鐨剆elect璇彞
SQL>set view_name,text_length from user_views;
SQL>set long 2000; 璇存槑錛氬彲浠ユ牴鎹鍥劇殑text_length鍊艱瀹歴et long 鐨勫ぇ灝?br />
SQL>select text from user_views where view_name=upper(&view_name);
鍏佸悓涔夎瘝
鏌ョ湅鍚屼箟璇嶇殑鍚嶇О
SQL>select * from user_synonyms;
涓冦佺害鏉熸潯浠?br />
鏌ョ湅鏌愯〃鐨勭害鏉熸潯浠?br />
SQL>select constraint_name, constraint_type,search_condition, r_constraint_name
from user_constraints where table_name = upper(&table_name);
SQL>select c.constraint_name,c.constraint_type,cc.column_name
from user_constraints c,user_cons_columns cc
where c.owner = upper(&table_owner) and c.table_name = upper(&table_name)
and c.owner = cc.owner and c.constraint_name = cc.constraint_name
order by cc.position;
鍏佸瓨鍌ㄥ嚱鏁板拰榪囩▼
鏌ョ湅鍑芥暟鍜岃繃紼嬬殑鐘舵?br />
SQL>select object_name,status from user_objects where object_type=FUNCTION;
SQL>select object_name,status from user_objects where object_type=PROCEDURE;
鏌ョ湅鍑芥暟鍜岃繃紼嬬殑婧愪唬鐮?br />
SQL>select text from all_source where owner=user and name=upper(&plsql_name);
]]>case鐨勫簲鐢?/title>http://m.tkk7.com/szhswl/articles/165184.html瀹嬮拡榪?/dc:creator>瀹嬮拡榪?/author>Tue, 04 Dec 2007 06:39:00 GMThttp://m.tkk7.com/szhswl/articles/165184.htmlhttp://m.tkk7.com/szhswl/comments/165184.htmlhttp://m.tkk7.com/szhswl/articles/165184.html#Feedback0http://m.tkk7.com/szhswl/comments/commentRss/165184.htmlhttp://m.tkk7.com/szhswl/services/trackbacks/165184.html
select sys_navigation_param_tb.*,
case when sys_navigation_param_tb.id in
(select sys_role_rihgts_tb.nav_param_id from sys_role_rihgts_tb where sys_role_rihgts_tb.role_id='1')
then 0
else 1 end flag
from sys_navigation_param_tb
select
case when (select count(id) from sys_role_rigths_tb) > 0 then sys_navigation_param_tb.group_name
else sys_navigation_param_tb.order_name
end
from sys_navigation_param_tb
]]>鏌ユ壘浣庡姡SQLhttp://m.tkk7.com/szhswl/articles/164943.html瀹嬮拡榪?/dc:creator>瀹嬮拡榪?/author>Mon, 03 Dec 2007 09:24:00 GMThttp://m.tkk7.com/szhswl/articles/164943.htmlhttp://m.tkk7.com/szhswl/comments/164943.htmlhttp://m.tkk7.com/szhswl/articles/164943.html#Feedback0http://m.tkk7.com/szhswl/comments/commentRss/164943.htmlhttp://m.tkk7.com/szhswl/services/trackbacks/164943.html 涓嬮潰鏄垜鏀惰棌鐨勪竴浜涙煡鎵綽ad sql鐨勬柟娉?
select * from (select buffer_gets, sql_text
from v$sqlarea
where buffer_gets > 500000
order by buffer_gets desc) where rownum<=30;
-- 鎵ц嬈℃暟澶氱殑SQL
select sql_text,executions from
(select sql_text,executions from v$sqlarea order by executions desc)
where rownum<81;
-- 璇葷‖鐩樺鐨凷QL
select sql_text,disk_reads from
(select sql_text,disk_reads from v$sqlarea order by disk_reads desc)
where rownum<21;
-- 鎺掑簭澶氱殑SQL
select sql_text,sorts from
(select sql_text,sorts from v$sqlarea order by sorts desc)
where rownum<21;
--鍒嗘瀽鐨勬鏁板お澶氾紝鎵ц鐨勬鏁板お灝戯紝瑕佺敤緇戝彉閲忕殑鏂規硶鏉ュ啓sql
set pagesize 600;
set linesize 120;
select substr(sql_text,1,80) "sql", count(*), sum(executions) "totexecs"
from v$sqlarea
where executions < 5
group by substr(sql_text,1,80)
having count(*) > 30
order by 2;
-- 娓告爣鐨勮瀵?/p>
set pages 300;
select sum(a.value), b.name
from v$sesstat a, v$statname b
where a.statistic# = b.statistic#
and b.name = 'opened cursors current'
group by b.name;
select count(0) from v$open_cursor;
select user_name,sql_text,count(0) from v$open_cursor
group by user_name,sql_text having count(0)>30;
--鏌ョ湅褰撳墠鐢ㄦ埛&username鎵ц鐨凷QL
select sql_text from v$sqltext_with_newlines where (hash_value,address) in
(select sql_hash_value,sql_address from v$session where username='&username')
order by address,piece;
]]>鏇存柊涓嶅悓琛ㄧ浉鍚屽瓧孌典笉鍚屽?/title>http://m.tkk7.com/szhswl/articles/164941.html瀹嬮拡榪?/dc:creator>瀹嬮拡榪?/author>Mon, 03 Dec 2007 09:22:00 GMThttp://m.tkk7.com/szhswl/articles/164941.htmlhttp://m.tkk7.com/szhswl/comments/164941.htmlhttp://m.tkk7.com/szhswl/articles/164941.html#Feedback0http://m.tkk7.com/szhswl/comments/commentRss/164941.htmlhttp://m.tkk7.com/szhswl/services/trackbacks/164941.html
SET SEND_STATE = (SELECT SEND_STATE
FROM PHS.SUBMIT
WHERE PHS.SUBMIT.ID = SA.ID
AND SUBSTR(SA.SEND_STATE, 15, 1) <>
AN.SUBMIT.SEND_STATE
AND SUBSTR(SA.SEND_STATE, 15, 1) IS NOT NULL)
WHERE SA.ISCHGSTATUS = 0 AND EXISTS
(SELECT 1
FROM PHS.SUBMIT PHS
WHERE PHS.ID = SA.ID
AND SUBSTR(SA.SEND_STATE, 15, 1) <> PHS.SEND_STATE
AND SUBSTR(SA.SEND_STATE, 15, 1) IS NOT NULL)
]]>閲嶅璁板綍鍜屽鐞?/title>http://m.tkk7.com/szhswl/articles/164893.html瀹嬮拡榪?/dc:creator>瀹嬮拡榪?/author>Mon, 03 Dec 2007 07:48:00 GMThttp://m.tkk7.com/szhswl/articles/164893.htmlhttp://m.tkk7.com/szhswl/comments/164893.htmlhttp://m.tkk7.com/szhswl/articles/164893.html#Feedback0http://m.tkk7.com/szhswl/comments/commentRss/164893.htmlhttp://m.tkk7.com/szhswl/services/trackbacks/164893.html1銆佹煡鎵捐〃涓浣欑殑閲嶅璁板綍錛岄噸澶嶈褰曟槸鏍規嵁鍗曚釜瀛楁錛坧eopleId錛夋潵鍒ゆ柇
select * from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
2銆佸垹闄よ〃涓浣欑殑閲嶅璁板綍錛岄噸澶嶈褰曟槸鏍規嵁鍗曚釜瀛楁錛坧eopleId錛夋潵鍒ゆ柇錛屽彧鐣欐湁rowid鏈灝忕殑璁板綍
delete from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
and rowid not in (select min(rowid) from people group by peopleId having count(peopleId )>1)
3銆佹煡鎵捐〃涓浣欑殑閲嶅璁板綍錛堝涓瓧孌碉級
select * from vitae a
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
4銆佸垹闄よ〃涓浣欑殑閲嶅璁板綍錛堝涓瓧孌碉級錛屽彧鐣欐湁rowid鏈灝忕殑璁板綍
delete from vitae a
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)
5銆佹煡鎵捐〃涓浣欑殑閲嶅璁板綍錛堝涓瓧孌碉級錛屼笉鍖呭惈rowid鏈灝忕殑璁板綍
select * from vitae a
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)
鍒╃敤rowid閲嶅璁板綍鐨勬煡璇㈣繕鍙互鐢ㄤ笅闈QL錛?br />
select * from people p1
where p1.rowid not in (select max(rowid) from people p2 where p2.peopleId = p1.peopleId)
]]>鍚屼竴鍒楀煎湪鍚屼竴鍗曟棤涓樉紺?/title>http://m.tkk7.com/szhswl/articles/164892.html瀹嬮拡榪?/dc:creator>瀹嬮拡榪?/author>Mon, 03 Dec 2007 07:42:00 GMThttp://m.tkk7.com/szhswl/articles/164892.htmlhttp://m.tkk7.com/szhswl/comments/164892.htmlhttp://m.tkk7.com/szhswl/articles/164892.html#Feedback0http://m.tkk7.com/szhswl/comments/commentRss/164892.htmlhttp://m.tkk7.com/szhswl/services/trackbacks/164892.html
chgdetail_custname
min(decode(seq, 1, serv_devcode, NULL)) || ',' ||
min(decode(seq, 2, serv_devcode, NULL)) || ',' ||
min(decode(seq, 3, serv_devcode, NULL))
chgdetail_roperatorid
from (select chgdetail_id,
chgdetail_custname,
serv_devcode,
row_number() over(partition by chgdetail_id order by chgdetail_id asc) seq
from (select c.id chgdetail_id,
c.custname chgdetail_custname,
serv.devcode serv_devcode
from chgdetail c
left outer join serv serv on c.racctid = serv.racctid
where
group by c.id,
c.custname,
serv.devcode))
where seq < 4
group by chgdetail_id,
chgdetail_custname
SQL璇存槑錛氬綋鏌ヨ鍑虹粨鏋滅殑鐩歌繛鐨勬暟閲?濡備笂SQL鍙姹傜數璇濆彿鍓嶄笁浣嶉氳繃“錛?#8221;鐩歌繛)鏈夐檺鍒舵垨鐩稿悓闇姹傛椂錛屽彲鐢╠ecode鐩歌繛銆?
]]>鍚屼竴鍒楀煎湪鍚屼竴鍗曞厓涓樉紺轟箣sys_connect_by_path鐨勫簲鐢?/title>http://m.tkk7.com/szhswl/articles/164881.html瀹嬮拡榪?/dc:creator>瀹嬮拡榪?/author>Mon, 03 Dec 2007 07:19:00 GMThttp://m.tkk7.com/szhswl/articles/164881.htmlhttp://m.tkk7.com/szhswl/comments/164881.htmlhttp://m.tkk7.com/szhswl/articles/164881.html#Feedback0http://m.tkk7.com/szhswl/comments/commentRss/164881.htmlhttp://m.tkk7.com/szhswl/services/trackbacks/164881.html
from (select id, upload_num_count, rn, lead(rn) over(partition by id order by rn) rn1
from (select 1 id, upload_num_count, row_number() over(order by upload_num_count desc) rn
from adp_yellowpage_sr))
start with rn1 is null
connect by rn1 = prior rn
SQL璇存槑錛氬皢adp_yellowpage_sr琛ㄤ腑鐨剈pload_num_count瀛楁鎺掑簭鍚庢樉紺哄湪鍚屼竴鍗曞厓涓紝鏄劇ず緇撴灉錛?br />
0,0,0,0,1,11,11,11,11,11,11,11,11,11,11,11,11,11,85,254,254,254,352,,,,,
select id,
login_id,
job_number,
user_name,
user_mobile,
user_duty,
user_status,
max(ltrim(sys_connect_by_path(role_name, ','), ',')) role_name
from (select usertb.id,
usertb.login_id,
usertb.job_number,
usertb.user_name,
usertb.user_mobile,
usertb.user_duty,
usertb.user_status,
roletb.role_name,
row_number() over(partition by usertb.id order by roletb.role_name) rn
from sys_user_info_tb usertb
left outer join sys_user_role_tb userrole on userrole.user_id =
usertb.id
left outer join sys_role_info_tb roletb on roletb.id =
userrole.role_id)
start with rn = 1
connect by prior rn + 1 = rn
and prior id = id
group by id,
login_id,
job_number,
user_name,
user_mobile,
user_duty,
user_status
SQL璇存槑錛氭湁涓変釜琛╯ys_user_role_tb鐢ㄦ埛淇℃伅琛紝sys_role_info_tb瑙掕壊淇℃伅琛紝sys_user_role_tb鐢ㄦ埛瑙掕壊鍏寵仈琛紝
姝QL瀹炵幇浜唕ole_name鍦ㄥ悓涓鍗曞厓涓互“錛?#8221;鐩歌繛鏄劇ず銆?br />