oracle֪ʶ£¨Ò»£©
sql½Å±¾£¬Ò²¾ÍÊÇÔÚÎļþÖÐдÓÐsqlÓï¾äµÄÎļþ£¬¿ÉÒÔÔÚsqlplusÖÐÔËÐС£
ÒýÈësql½Å±¾
sqlplus Óû§Ãû/ÃÜÂë @sql½Å±¾.sql
£¨×¢Ò⣺ÔÚÓû§ÃûÃÜÂëÊäÈë½áÊøºóÒ»¶¨Òª¼Ó¿Õ¸ñÈ»ºóÔÙд@sql½Å±¾£©
OracleÖеĿÕÖµ»áµ±×÷ÎÞÇî´ó´¦Àí£¬Æäʵ¿ÕÖµ¸ù±¾¾Í²»»á´æ´¢£¬Ö»ÊÇ¿´×÷ÊÇÎÞÇî´ó¡£
OracleÖпØÖÆ´¦Àíº¯Êý NVL(×Ö¶ÎÃû£¬Öµ)£¬Õâ¸ö×Ö¶ÎÖеĿÕÖµÌæ»»ÎªÖ¸¶¨Öµ£¬Èç¹û²»Îª¿Õ£¬Ôò»á·µ»ØÆäÔÖµ¡£
Àý£ºselect (salary*12)*(NVL(commission_pct,0)/100+1) salary,first_name
from s_emp;
distinct¹Ø¼ü×Ö£¬È¥µôÖØ¸´ÐУ¨Õâ¸ö¹Ø¼ü×ֻᴦ·¢ÅÅÐò²Ù×÷£©
Àý£º select distinct dept_id,title from s_emp;
×¢Ò⣺distinct£¬¹Ø¼ü×ÖÖ®ºó»á¶Ôfrom֮ǰµÄ×ֶνøÐÐÅÅÖØ²Ù×÷¡£
columnÃüÁÕâÊǸösqlplusÃüÁ
columnÃüÁî ÁиñʽµÄ¶¨Òå
column Ä¿±êÁÐÃû ²é¿´Õâ¸öÀàÊÇ·ñ¶¨ÒåÁ˸ñʽ
column Ä¿±êÁÐÃû format a.. ÉèÖÃÁпí
column last_name heading 'Employee|Name'£¨ÉèÖÃÌâÍ·£© FORMAT A15
ÕâÆäÖеÄ'|'ÊÇ»»Ðзû
column salary justify left format $99,990.00£¨¶¨ÒåÊý×ÖÏÔʾ¸ñʽ£©
×¢Ò⣺Èç¹û²»Âú×ãÏÔʾµÄ¸ñʽ£¬¾Í»á°ÑÊý¾ÝÏÔʾΪ"#"
column ÁÐÃû clear £¨Çå³ýÁиñʽ¶¨Ò壩
×¢Ò⣺ֻÓÐsqlplusÃüÁî²ÅÓмòд£¬²¢ÇÒÔÚʹÓÃsqlplusÃüÁîʱ½áβҲ²»Äܼӷֺš£
Ñ¡Ôñ²Ù×÷
order by ÅÅÐò×Ó¾ä ASC£¨Ä¬ÈÏ£¬ÉýÐò£© DESC£¨½µÐò£©
order by Ä¿±êÁÐÃû£¨±ðÃû£© ÅÅÐò˳Ðò£¨²»Ð´ÅÅÐò˳Ðò£¬»áĬÈÏΪÉýÐòÅÅÐò£©
Àý£ºselect first_name from s_emp order by first_name;
select first_name from s_emp order by first_name desc;
×¢Ò⣺ÉýÐò¿ÕÖµÔÚ½á¹ûµÄĩ⣬½µÐò¿ÕÖµÔÚ½á¹ûµÄ×îÇ°Ãæ¡£
where×Ó¾ä
where×Ó¾äʹÓÃÔÚ select ... from ... ºóÃæ£¬ÓÃÀ´Ñ¡ÔñËùÐ裨·ûºÏÌõ¼þµÄ£©µÄ¼Ç¼
whereºóÃæ¸úµÄÊDZí´ïʽ Ò²¾ÍÊÇ XXX=XXX£¬ XXX between X and X £¬XXX in£¨X£¬X£¬X£©
like '...' ͨÅä²éѯ
between ... and ... ,±íʾ½á¹ûÔÚÕâÖ®¼ä£¬between andÊÇÒ»¸ö±ÕÇø¼ä£¬
Ò²¾ÍÏ൱ÓÚ... <
Ïà¹ØÎĵµ£º
Ò»£¬OracleÊý¾Ý¿âÓû§¼ò½é
ÔÚOracleÊý¾Ý¿âÖÐÈκζÔÏó¶¼ÊôÓÚÒ»¸öÌØ¶¨Óû§£¬»òÕß˵һ¸öÓû§ÓëͬÃûµÄģʽÏà¹ØÁª¡£
ÒªÁ¬½Óµ½OracleÊý¾Ý¿âÐèÒªÒ»¸öÓû§ÕÊ»§£¬¸ù¾ÝÐèÒªÊÚÓèµÄ²Ù×÷ȨÏÞ¡£
1£¬Ä¬ÈÏÊý¾Ý¿âÓû§Ä£Ê½£º
Sys:Êý¾Ý¿â×ֵ䣨´æ´¢±»¹ÜÀí¶ÔÏóËùÓÐÐÅÏ¢£©ºÍÊÓͼ´æ´¢ÔÚ¸ÃģʽÖС£ÏµÍ³¼¶Óû§¡£ ......
FORALLÓï¾äµÄÒ»¸ö¹Ø¼üÐԸĽø£¬Ëü¿É´ó´ó¼ò»¯´úÂ룬²¢ÇÒ¶ÔÓÚÄÇЩҪÔÚPL/SQL³ÌÐòÖиüкܶàÐÐÊý¾ÝµÄ³ÌÐòÀ´Ëµ£¬Ëü¿ÉÏÔÖøÌá¸ßÆäÐÔÄÜ¡£
1:
ÓÃFORALLÀ´ÔöÇ¿DMLµÄ´¦ÀíÄÜÁ¦
OracleΪOracle8iÖеÄPL/SQLÒýÈëÁËÁ½¸öеÄÊý¾Ý²Ù×ÝÓïÑÔ£¨DML£©Óï¾ä£ºBULK COLLECTºÍFORALL¡£ÕâÁ½¸öÓï¾äÔÚPL/SQLÄÚ²¿½øÐÐÒ»ÖÖÊý×é´¦Àí
£»BULK COLLE ......
Oracle Database 10g ÌṩÁËÒ»¸öÏÔÖø¸Ä½øµÄ¹¤¾ß£º×Ô¶¯¹¤×÷¸ºÔØÐÅÏ¢¿â (AWR:Automatic Workload Repository)¡£Oracle ½¨ÒéÓû§ÓÃÕâ¸öÈ¡´ú Statspack¡£AWR ʵÖÊÉÏÊÇÒ»¸ö Oracle µÄÄÚÖù¤¾ß£¬Ëü²É¼¯ÓëÐÔÄÜÏà¹ØµÄͳ¼ÆÊý¾Ý£¬²¢´ÓÄÇЩͳ¼ÆÊý¾ÝÖе¼³öÐÔÄÜÁ¿¶È£¬ÒÔ¸ú×ÙDZÔÚµÄÎÊÌâ¡£Óë Statspack ²»Í¬£¬¿ìÕÕÓÉÒ»¸ö³ÆÎª MMON µÄеĺó ......
½ñÄêµÄOracleÈ«Çò´ó»áÓÚ10ÔÂ11ÈÕ£15ÈÕÔÚÃÀ¹ú¾É½ðɽµÄMosconeÖÐÐÄÒѾÀ¿ªÐòÄ»ÁË¡£
¡¡¡¡ Oracle¶ÔSun¹«Ë¾µÄ³¤ÆÚ¼Æ»®ÎÞÒÉÊDZ¾´ÎOOW´ó»áµÄ½¹µã¡£µ«ÔÚ̸ÂÛÕâ¸ö»°Ìâ֮ǰ£¬ÎÒÃÇ×¼±¸ÁËÒ»×é´ó»áµÄÓÐȤÊý¾Ý£¬ÏÈÈôó¼Ò¶Ô±¾´Î´ó»áÓиöÕûÌåµÄÓ¡Ïó¡£
¡¡¡¡ÓйØÕû¸ö´ó»áµÄÊý×Ö£º
¡¡¡¡· ½ü4.3ÍòÈ˵½»á
¡¡¡¡· ΪÃÀ¹ ......
HWMÊÇoracleÖÐblockÓÐûÓÐʹÓõķֽçÏߣ¬Ëü»áËæ×ÅÊý¾ÝµÄinsert¶øÉÏÉý£¬µ«Ëü²¢²»»áËæÊý¾ÝµÄdelete¶øÏ½µ£¬Òò´ËÈ«±íɨÃèµÄʱ¼ä²¢²»ÒòÊý¾ÝµÄdelete¶ø¼õÉÙ£¬Ïà·´¿ÉÄÜÓÉÓÚ¿éÇå³ý·´¶øÈ«±íɨÃèʱ¼äÔö¼Ó£¬¿ÉÒÔÓÃÏÂÃæ·½·¨µÄÈÎÒ»Ò»ÖÖÀ´½µµÍHWM£º
µÚÒ»ÖÖ£ºshrink
ÊÊÓÃÓÚ10gÒÔºóµÄ°æ±¾£¬Ç°ÌáÊÇÕâ¸ö±í£¬Ë÷Òý£¬ÎﻯÊÓͼ»òÎﻯÊÓͼlogËùÔ ......