Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

DBA³£ÓÃsql(¶þ)

 session״̬£º
STATUS VARCHAR2(8) Status of the session:
ACTIVE - Session currently executing SQL
INACTIVE - sql¼°ÆäsessionûÓÐÊÍ·Å»òÕý³£Í˳ö......
KILLED - Session marked to be killed
CACHED - Session temporarily cached for use by Oracle*XA
SNIPED - Session inactive, waiting on the client
²éѯÊý¾Ý¿âÖгÖËøºÍµÈ´ýËøµÄÓû§ÐÅÏ¢
select  distinct o.object_name, sh.sid "SID", sh.SERIAL# "SERIAL", sh.username||'('||sh.sid||','||sh.SERIAL#||')' "Holder",
        sw.username||'('||sw.sid||','||sw.SERIAL#||')' "Waiter",
        decode(lh.lmode, 1, 'null', 2,
              'row share', 3, 'row exclusive', 4,  'share',
              5, 'share row exclusive' , 6, 'exclusive')  "Lock Type"
  from v$session sw, v$lock lw,all_objects o,  v$session sh, v$lock lh
where lh.id1  = o.object_id
  and  lh.id1  = lw.id1
  and  sh.sid  = lh.sid
  and  sw.sid  = lw.sid
  and  sh.lockwait is null
  and  sw.lockwait is not null
  and  lh.type = 'TM'
  and  lw.type = 'TM';
select /*+ NO_MERGE(a) NO_MERGE(b) NO_MERGE(c) */ 'Wait' "Status", a.username, a.machine, a.sid, a.serial#, a.last_call_et "Seconds", b.id1, c.sql_text "SQL"
from v$session a, v$lock b, v$sqltext c
where a.username is not null
and a.lockwait = b.kaddr
and c.hash_value =a.sql_hash_value
union
select /*+ NO_MERGE(a) NO_MERGE(b) NO_MERGE(c) */ 'Lock' "Status", a.username, a.machine, a.sid, a.serial#, a.last_call_et "Seconds", b.id1, c.sql_text "SQL"
from v$session a, v$lock b, v$sqltext c
where b.id1 in
(select /*+ NO_MERGE(d) NO_MERGE(e) */ distinct e.id1
from v$session d, v$lock e
where d.lockwait = e.kaddr)
and a.username is not null
and a.sid = b.sid
and b.request=0
and c.ha


Ïà¹ØÎĵµ£º

¼òµ¥SQLÓï¾äС½á

ΪÁË´ó¼Ò¸üÈÝÒ×Àí½âÎÒ¾Ù³öµÄSQLÓï¾ä£¬±¾Îļٶ¨ÒѾ­½¨Á¢ÁËÒ»¸öѧÉú³É¼¨¹ÜÀíÊý¾Ý¿â£¬È«ÎľùÒÔѧÉú³É¼¨µÄ¹ÜÀíΪÀýÀ´ÃèÊö¡£
¡¡¡¡1.ÔÚ²éѯ½á¹ûÖÐÏÔʾÁÐÃû£º
¡¡¡¡a.ÓÃas¹Ø¼ü×Ö£ºselect name as 'ÐÕÃû' from students order by age
¡¡¡¡b.Ö±½Ó±íʾ£ºselect name 'ÐÕÃû' from students order by age
¡¡¡¡2.¾«È·²éÕÒ:
¡¡¡¡a.ÓÃ ......

ÇÉÓö¯Ì¬ºêʵÏÖSQLÖд«µÝÖØ¸´²ÎÊý

ÈóǬ±¨±í¿ÉÒÔͨ¹ýSQL¼ìË÷ºÍ¸´ÔÓSQLÉú³ÉÊý¾Ý¼¯¡£µ±SQLÖÐÐèÒª´«Èë¶à¸ö²ÎÊýʱ£¬ÒªÔÚÉè¼ÆÆ÷ÖÐͨ¹ý ÅäÖÃ-²ÎÊý ¶¨ÒåÏàÓ¦µÄ²ÎÊý£¬È»ºóÔÙ°ÑSQLÖÐÐèÒª²ÎÊýµÄµØ·½Ìæ»»³É?£¬×îºó»¹ÒªÔÚSQL±à¼­Æ÷ÖÐÌí¼Ó¶ÔÓ¦?µÄ²ÎÊý¡£ÕâÑùµ±SQLÖÐÓжàÉÙ¸öÎʺţ¬ÎÒÃǾÍÐèÒªÌí¼Ó¶àÉÙ¸ö²ÎÊý¡£µ±SQLÖÐÓõ½µÄ²ÎÊý±È½ÏÉÙʱ£¬²Ù×÷ÆðÀ´»¹±È½Ï·½±ã¡£µ«µ±ÒµÎñ±È½Ï¸´ ......

sql¿ìËÙÈëÃÅ

 
SQLÓïÑÔ¿ìËÙÈëÃÅ
ä½ Ïª ɳ
Àî璟
ÊÖ¾íÕæÖéÉÏÓñ¹³,ÒÀǰ´ººÞËøÖØÂ¥, ·çÀïÂ仨˭ÊÇÖ÷, Ë¼ÓÆÓÆ
ÇàÄñ²»´«ÔÆÍâÐÅ,¶¡Ïã¿Õ½áÓêÖгî, »ØÊ×Â̲¨Èý³þĺ, ½ÓÌìÁ÷
SQLÓïÑÔ¿ìËÙÈëÃÅ
SQLÊÇÓ¢ÎÄStructured Query LanguageµÄËõд£¬Òâ˼Ϊ½á¹¹»¯²éѯÓïÑÔ¡£SQLÓïÑÔµÄÖ÷Òª¹¦ÄܾÍÊÇͬ¸÷ÖÖÊý¾Ý¿â½¨Á¢ÁªÏµ£¬½øÐйµÍ¨¡£°´ÕÕA ......

SQL ÓÐÌõ¼þµØÉ¸Ñ¡Öظ´Êý¾Ý

 --»ù´¡Á˽⣺
1) select distinct name from table --´ò¿ªÖظ´¼Ç¼µÄµ¥¸ö×Ö¶Î
2) select * from table where fid in(Select min(fid) from table group by name)--´ò¿ªÖظ´¼Ç¼µÄËùÓÐ×Ö¶ÎÖµ
3) select * from table where name in(select name from table group by name having count(name)=1)--´ò¿ªÖظ´ÈÎÒâ´ÎÊýµ ......

SQLÁ¬½Ó·ÖÀ༰ʹÓÃ˵Ã÷

 Í¨¹ýÁ¬½ÓÔËËã·û¿ÉÒÔʵÏÖ¶à¸ö±í²éѯ¡£Á¬½ÓÊǹØÏµÊý¾Ý¿âÄ£Ð͵ÄÖ÷ÒªÌØµã£¬Ò²ÊÇËüÇø±ðÓÚÆäËüÀàÐÍ
Êý¾Ý¿â¹ÜÀíϵͳµÄÒ»¸ö±êÖ¾¡£
ÔÚ¹ØÏµÊý¾Ý¿â¹ÜÀíϵͳÖУ¬±í½¨Á¢Ê±¸÷Êý¾ÝÖ®¼äµÄ¹ØÏµ²»±ØÈ·¶¨£¬³£°ÑÒ»¸öʵÌåµÄËùÓÐÐÅÏ¢´æ·ÅÔÚ
Ò»¸ö±íÖС£µ±¼ìË÷Êý¾Ýʱ£¬Í¨¹ýÁ¬½Ó²Ù×÷²éѯ³ö´æ·ÅÔÚ¶à¸ö±íÖеIJ»Í¬ÊµÌåµÄÐÅÏ¢¡£Á¬½Ó²Ù×÷¸øÓû ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ