Oracle Êý¾ÝÉú³É Ë÷Òý
1.½¨±í
CREATE TABLE qq(
qq_num integer
);
2.²åÈëÊý¾Ý
²åÈëÊý¾ÝµÄ·½·¨ÓкܶàÖÖ£¬µ«ÊÇÒª²åÈë3ÒÚÊý¾Ý£¬±ØÐëÒªÓиßЧµÄËã·¨¡£ÔÚ²åÈëÊý¾ÝʱÎÒÓÃÁË×µÄ°ì·¨£¬²ÉÓÃPL/SQLÀûÓÃÁ÷³Ì¿ØÖƵÄLOOPÓï¾ä²åÈ롣ͬʱÎÒÒ²¿´ÁËÍøÉϵIJåÈëЧÂʵÄÓÅ»¯£¬ÔõÑùÀûÓýÏÉÙµÄʱ¼äÉú³É½Ï¶àµÄ²âÊÔÊý¾Ý¡£¸øÎÒÓ¡ÏóÉî¿ÌµÄÊÇÀûÓÃÖÖ×Ó±íÀ´Éú³É½Ï¶àµÄÊý¾Ý¡£
ÕâÑù×öµÄºÃ´¦ÊDZ¾ÉíÊý¾Ý¾ÍÔÚ±¾µØ´ÅÅÌ£¬¼õÉÙÁË´æÈ¡µÄI/O²Ù×÷£¬Êý¾ÝÉú³É½Ï¿ì¡£
ÎÒ²ÉÓÃ×µÄ°ì·¨ÀûÓÃ8СʱÉú³ÉÁË2ÒÚ¶àÌõÊý¾Ý¼Ç¼¡£
3.Ë÷ÒýµÄ½¨Á¢
ÓÉÓÚÒÑ´æÔڵļǼÓÐ2ÒÚÌõ£¬²ÉÓÃCREATE INDEX qq_num_index ON qq(qq_num);ºÄ·Ñʱ¼ä½ü1Сʱ¡£
Ë÷ÒýµÄºÃ´¦:²éѯЧÂÊÌá¸ß£¬Ë÷ÒýÏà¹ØµÄ“Ìî³äÒò×Ó”¡£
count£¨£©º¯ÊýʼÖÕ²»×ßË÷Òý£¬¶¼ÊÇÈ«ÅÌɨÃ裬»¹Î´ÕÒµ½½â¾ö°ì·¨¡£Ò²¾ÍÊÇÒÔÏÂPL/SQLÖ´ÐеÄʱ¼äÔÚ½¨Á¢Ë÷ÒýÇ°ºóÊÇÒ»ÑùµÄ¡£
DECLARE
count_num NUMBER;
BEGIN
dbms_output.put_line('Óï¾äÖ´ÐпªÊ¼Ê±¼ä:'||systimestamp);
SELECT COUNT(qq_num) INTO count_num from qq WHERE qq_num IS NOT NULL;
dbms_output.put_line('½á¹û:'||count_num);
dbms_output.put_line('Óï¾äÖ´ÐнáÊøʱ¼ä:'||systimestamp);
END;
/
µ«Êǽ¨Á¢Ë÷Òýºó£¬SELECT MAX£¨qq_num£© ºÍÆäËûÏà¹ØµÄÓï¾äµÄÖ´ÐÐʱ¼äÁ¢¼´¼õÉÙÁ˺ܶࡣ
ÒÔÏÂÊÇ´úÂ룺
DECLARE
count_num NUMBER;
BEGIN
dbms_output.put_line('Óï¾äÖ´ÐпªÊ¼Ê±¼ä:'||systimestamp);
SELECT MAX(qq_num) INTO count_num from qq;
dbms_output.put_line('½á¹û:'||count_num);
dbms_output.put_line('Óï¾äÖ´ÐнáÊøʱ¼ä:'||systimestamp);
END;
/
½¨Á¢Ë÷ÒýÇ°£ºÖ´ÐÐʱ¼äΪ1·Ö7Ãë,Ë÷Òýºó0.2ÃëÄÚÍê³É¡£
½¨Á¢Ë÷ÒýÊÇÒÔ´æ´¢¿Õ¼äΪ´ú¼Û»»È¡Ê±¼äЧÂʵÄÌá¸ß¡£
Õâµ±ÖÐÓÐautotrace¿ÉÒÔ×Ô¶¯ÏÔʾSQLÓï¾äµÄÖ´Ðмƻ®£¬ÕâÖֲ鿴±ØÐëÔÚSQL *PLUSÏÂ.
¿ªÆôautotraceµÄ²½ÖèÈçÏÂ:
--DBA³õ´Î±ØÐëÖ´ÐÐ
CREATE ROLE plustrace;--ÐèÒªÓµÓÐȨÏÞ
GRANT SELECT ON v_$sesstat TO plustrace;--ÐèÒªÓÐGRANTȨÏÞ
GRANT SELECT ON v_$mystat TO plustrace;
GRANT SELECT ON v_$statname TO plustrace;
--¿ªÆô×Ô¶¯¸ú×Ù
SET AUTOTRACE ON;
Ïà¹ØÎĵµ£º
1¡¢set linesize 100; ÉèÖó¤¶È
2¡¢set pagesize 30; ÉèÖÃÿҳÏÔʾÊýÄ¿
3¡¢em a.sql ´ò¿ª¼Çʱ¾
4¡¢@ a Ö´ÐÐÎļþaÖеĴúÂ룬¿ÉÖ¸¶¨ÎļþµÄ·¾¶ @d:a.txt ......
ÈçºÎÔ¶³ÌÅжÏOracleÊý¾Ý¿âµÄ°²×°Æ½Ì¨
¡¡¡¡select * from v$version;
¡¡¡¡²é¿´±í¿Õ¼äµÄʹÓÃÇé¿ö
¡¡¡¡select sum(bytes)/(1024*1024) as free_space,tablespace_name
¡¡¡¡from dba_free_space
¡¡¡¡group by tablespace_name;
¡¡¡¡SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES ......
Êý¾Ý¿âÃû(DB_NAME)¡¢ÊµÀýÃû(Instance_name)¡¢ÒÔ¼°²Ù×÷ϵͳ»·¾³±äÁ¿(ORACLE_SID)
ÔÚORACLE7¡¢8Êý¾Ý¿âÖÐÖ»ÓÐÊý¾Ý¿âÃû(db_name)ºÍÊý¾Ý¿âʵÀýÃû(instance_name)¡£ÔÚORACLE8i¡¢9iÖгöÏÖÁËеIJÎÊý£¬¼´Êý¾Ý¿âÓòÃû(db_domain)¡¢·þÎñÃû(service_name)¡¢ÒÔ¼°²Ù×÷ϵͳ»·¾³±äÁ¿(ORACLE_SID)¡£ÕâЩ¶¼´æÔÚÓÚͬһ¸öÊý¾Ý¿âÖеıêʶ£¬ÓÃÓÚÇ ......
×î½ü´ÓExcelÖе½ÁËһЩÊý¾Ý£¬½á¹ûÒ»¸öÁеÄÊý¾ÝÊÇÒÔ¶ººÅ·Ö¸ôµÄ×Ö·û´®£¬Ïë°ÑËü²ð·Ö¿ªÕÒµ½ÁËϱߵķ½·¨£¬Ìù³öÀ´·ÖÏíһϣº
CREATE OR REPLACE PROCEDURE sptstr (srcstr varchar2) as
stmp varchar2(2000);
begin &n ......