DBA³£ÓÃsql(Ò»)
--¼à¿ØË÷ÒýÊÇ·ñʹÓà alter index &index_name monitoring usage; alter index &index_name nomonitoring usage; select * from v$object_usage where index_name = &index_name;
--ÇóÊý¾ÝÎļþµÄI/O·Ö²¼ select df.name,phyrds,phywrts,phyblkrd,phyblkwrt,singleblkrds,readtim,writetim from v$filestat fs,v$dbfile df where fs.file#=df.file# order by df.name;
--Çóij¸öÒþ²Ø²ÎÊýµÄÖµ col ksppinm format a54 col ksppstvl format a54 select ksppinm, ksppstvl from x$ksppi pi, x$ksppcv cv where cv.indx=pi.indx and pi.ksppinm like '_%' escape '' and pi.ksppinm like '%meer%';
--ÇóϵͳÖнϴóµÄlatch select name,sum(gets),sum(misses),sum(sleeps),sum(wait_time) from v$latch_children group by name having sum(gets) > 50 order by 2;
--Çó¹éµµÈÕÖ¾µÄÇл»ÆµÂÊ(Éú²úϵͳ¿ÉÄÜʱ¼ä»áºÜ³¤) select start_recid,start_time,end_recid,end_time,minutes from (select test.*, rownum as rn from (select b.recid start_recid,to_char(b.first_time,'yyyy-mm-dd hh24:mi:ss') start_time, a.recid end_recid,to_char(a.first_time,'yyyy-mm-dd hh24:mi:ss') end_time,round(((a.first_time-b.first_time)*24)*60,2) minutes from v$log_history a,v$log_history b where a.recid=b.recid+1 and b.first_time > sysdate - 1 order by a.first_time desc) test) y where y.rn < 30
--Çó»Ø¹ö¶ÎÕýÔÚ´¦ÀíµÄÊÂÎñ select a.name,b.xacts,c.sid,c.serial#,d.sql_text from v$rollname a,v$rollstat b,v$session c,v$sqltext d,v$transaction e where a.usn=b.usn and b.usn=e.xidusn and c.taddr=e.addr and c.sql_address=d.address and c.sql_hash_value=d.hash_value order by a.name,c.sid,d.piece;
--Çó³öÎÞЧµÄ¶ÔÏó select 'alter procedure '||object_name||' compile;' from dba_objects where status='INVALID' and wner='&' and object_type in ('PACKAGE','PACKAGE BODY'); / select owner,object_name,object_type,status from dba_objects where status='INVALID';
--Çóprocess/sessionµÄ״̬ select p.pid,p.spid,s.program,s.sid,s.serial# from v$process p,v$session s where s.paddr=p.addr;
--Çóµ±Ç°sessionµÄ״̬ select sn.name,ms.value from v$mystat ms,v$statname sn where ms.s
Ïà¹ØÎĵµ£º
ms sql ¸üбíAÖÐijÁÐΪ±íBÖеÄÖµ
select *
from dbo.NT_areapin
go
select *
from dbo.NT_dict_area
update NT_areapin
set AllNamePin='PengShui'
from NT_areapin
where AreaId='486'
go
update NT_dict_area
set BriefNamePin = NT_areapin.BriefNamePin,AllNamePin = NT_areapin.AllNamePin
from N ......
ΪÁË´ó¼Ò¸üÈÝÒ×Àí½âÎÒ¾Ù³öµÄSQLÓï¾ä£¬±¾Îļٶ¨ÒѾ½¨Á¢ÁËÒ»¸öѧÉú³É¼¨¹ÜÀíÊý¾Ý¿â£¬È«ÎľùÒÔѧÉú³É¼¨µÄ¹ÜÀíΪÀýÀ´ÃèÊö¡£
¡¡¡¡1.ÔÚ²éѯ½á¹ûÖÐÏÔʾÁÐÃû£º
¡¡¡¡a.ÓÃas¹Ø¼ü×Ö£ºselect name as 'ÐÕÃû' from students order by age
¡¡¡¡b.Ö±½Ó±íʾ£ºselect name 'ÐÕÃû' from students order by age
¡¡¡¡2.¾«È·²éÕÒ:
¡¡¡¡a.ÓÃ ......
/*--text×ֶεÄÌæ»»´¦Àí
--*/
--´´½¨Êý¾Ý²âÊÔ»·¾³
--create table #tb(aa text)
declare @s_str varchar(8000),@d_str varchar(8000), --¶¨ÒåÌæ»»µÄ×Ö·û´®
......
ÊÖ¶¯ÇåÀí
1¡¢´ò¿ª²éѯ·ÖÎöÆ÷£¬ÊäÈëÃüÁîDUMP TRANSACTION Êý¾Ý¿âÃû WITH NO_LOG
2¡¢ÔÙ´ò¿ªÆóÒµ¹ÜÀíÆ÷--ÓÒ¼üÄãҪѹËõµÄÊý¾Ý¿â--ËùÓÐÈÎÎñ--ÊÕËõÊý¾Ý¿â--ÊÕËõÎļþ--Ñ¡ÔñÈÕÖ¾Îļþ--ÔÚÊÕËõ·½Ê½ÀïÑ¡ÔñÊÕËõÖÁ: ,ÕâÀï»á¸ø³öÒ»¸öÔÊÐíÊÕËõµ½µÄ×îСMÊý,Ö±½ÓÊäÈëÕâ¸öÊý,È·¶¨¾Í¿ÉÒÔÁË¡£
Èç1)
×Ô¶¯ÇåÀí
ÆóÒµ¹ÜÀíÆ÷-¡·¹ÜÀí-¡·sql ......
ͨ¹ýÁ¬½ÓÔËËã·û¿ÉÒÔʵÏÖ¶à¸ö±í²éѯ¡£Á¬½ÓÊǹØϵÊý¾Ý¿âÄ£Ð͵ÄÖ÷ÒªÌص㣬ҲÊÇËüÇø±ðÓÚÆäËüÀàÐÍ
Êý¾Ý¿â¹ÜÀíϵͳµÄÒ»¸ö±êÖ¾¡£
ÔÚ¹ØϵÊý¾Ý¿â¹ÜÀíϵͳÖУ¬±í½¨Á¢Ê±¸÷Êý¾ÝÖ®¼äµÄ¹Øϵ²»±ØÈ·¶¨£¬³£°ÑÒ»¸öʵÌåµÄËùÓÐÐÅÏ¢´æ·ÅÔÚ
Ò»¸ö±íÖС£µ±¼ìË÷Êý¾Ýʱ£¬Í¨¹ýÁ¬½Ó²Ù×÷²éѯ³ö´æ·ÅÔÚ¶à¸ö±íÖеIJ»Í¬ÊµÌåµÄÐÅÏ¢¡£Á¬½Ó²Ù×÷¸øÓû ......