½üÀ´½ÓÁ˸ö¼òµ¥µÄϵͳ×ö£¬Íâ°üµÄ£¬ÓõÄÊý¾Ý¿âÊÇoracle8i,
Ò»¿ªÊ¼ÎÒʹÓà ojdbc6.jarÀ´×öÁ¬½Ó£¬Á¬²»ÉÏ£¬ÕÒÒ»·¬£¬ÔÀ´¹Ù·½oracle8i³öµÄÇý¶¯Ö»ÓÐ class12.jar ºÍclass14.jar ,×îÒªÃüµÄÊDz»Ö§³Öjdk1.4¼°1.4ÒÔÉϵģ¬¹¤×÷Á¿ÂíÉϾÍÉÏÀ´ÁË¡£²»¸ÊÐÄ°¡¡£
×îºóÊÔÁËÏ£¬ÄÜÓõÄÖ»ÓÐojadb14.jar £¬Á¬ÉÏÁË£¬²»¹ýͨ¹ýhibernateÉú³ÉµÄsqlʵÔÚÌ«Àã¬top 10¶¼Éú³É³öÀ´£¬²¿·ÖÓï¾äÄÜÓ㬲¿·Ö²»ÄÜÓ㬴󲿷ֲ»ÄÜÓ㬺öàÇé¿ö¶¼ÊÇÊÖдµÄsql.
ÊÖдµÄҲͦÊÇÀÛÁË£¬Ò»¸öÏîÄ¿¼Ó°àÁ˺ÃЩÌì¡£
²»¹ýÒ²ÓÐЩÐĵã¬ÀýÈç orcale µÄ·ÖÒ³,Èç¹ûheibernateÄÜÓõĻ°¾Í²»×Ô¸öдÁË
select * from
(select row_.*, rownum from (
select * from table_name where a =? order by id
) where rownum <=50
)where rownum >10 ......
ת£ºhttp://hi.baidu.com/mcj0127/blog/item/111a900777db06c87b89473c.html
SELECT FOR UPDATE Ïà¹ØµÄ֪ʶ
Ò»¸öÓʼþ·¢Ë͵ÄÓ¦Óûáÿ¹ýÒ»¶¨µÄʱ¼äƬȥÊý¾Ý¿âÖÐȡδ·¢µÄÓʼþÈ»ºó·¢ËÍÓʼþ£¬³É¹¦ºó½«Êý¾Ý¿âÖÐÓʼþ±êʶδ·¢¸ÄΪÒÑ·¢¡£
Õâ¸öÓ¦Óò¿ÊðÔÚwebsphereÉÏ£¬websphere²ÉÓÃÊÇ´¹Ö±¿Ë¡£¬ÓÐ4¸öserver,µ±4¸öserver¶¼¿ªÆôµÄʱºò£¬¾Í³öÏÖͬʱ·¢4·âÏàͬµÄÓʼþ¸øͬһ¸öÓû§¡£
Õâʱ£¬for updateËø¾Í¿ÉÒÔ½â¾öÕâ¸öÎÊÌâ!
1:״̬½âÊÍ
statement: Ò»¸öSQLÓï¾ä¡£
session: Ò»¸öÓÉORACLEÓû§²úÉúµÄÁ¬½Ó£¬Ò»¸öÓû§¿ÉÒÔ²úÉú¶à¸öSESSION £¬µ«Ï໥֮¼äÊǶÀÁ¢µÄ¡£
transaction:ËùÓеĸı䶼¿ÉÒÔ»®·Öµ½transactionÀһ¸ötransaction°üº¬Ò»¸ö»ò¶à¸öSQL¡£µ±Ò»¸öSESSION½¨Á¢µÄʱºò¾ÍÊÇÒ»¸öTRANSACTION¿ªÊ¼µÄʱ¿Ì£¬´Ëºó transactionµÄ¿ªÊ¼ºÍ½áÊøÓÉDCL¿ØÖÆ£¬Ò²¾ÍÊÇÿ¸öCOMMIT/ROLLBACK¶¼±êʾ×ÅÒ»¸ötransactionµÄ½áÊø¡£
consistency£ºÊǶÔÓÚstatement¼¶±ð¶ø²»ÊÇtransaction¼¶±ðÀ´ËµµÄ¡£sql statement µÃµ½µÄÊý¾Ý¶¼ÊÇÒÔsql statement¿ªÊ¼µÄIMAGE¡£
2:sql½âÊÍ
LOCKµÄ»ù±¾Çé¿ö: update, insert ,delete, select ... for update»áLOCKÏàÓ¦µÄROW ¡£
Ö»ÓÐÒ»¸öTRANS ......
Oracle ÎÞ¼àÌý³ÌÐò
½üÈÕ±¾µØµÄOracleÊý¾Ý¿âÎÞ·¨Á¬½Ó£¬Å׳öÎÞ¼àÌý³ÌÐò´íÎó£¬baigoogleduһϣ¬×ܽáÁËÈçϽâ¾ö·½°¸£º
First£º
Ò»¡¢ÔËÐмàÌýÆ÷
¡¡¡¡ÔÚCMDÖÐÊäÈëÒÔÏÂÄÚÈÝ:
C:>lsnrctl
LSNRCTL for 32-bit Windows: Version 8.1.6.0.0 - Production on 14-3ÔÂ -2003 14:17
:51(c) Copyright 1998, 1999, Oracle Corporation. All rights reserved.
¡¡¡¡»¶ÓÀ´µ½LSNRCTL£¬Çë¼üÈë"help"ÒÔ»ñµÃÐÅÏ¢¡£
¡¡¡¡LSNRCTL> status
¡¡¡¡Á¬½ÓÖÁ(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=robust)(PORT=1521)))
¡¡¡¡TNS-01103: µØÖ·µÄÐÒéרÓÃ×é¼þÖ¸¶¨²»ÕýÈ·
¡¡¡¡TNS-12541: TNS£ºÎÞ¼àÌýÆ÷
¡¡¡¡TNS-12560: TNS£ºÐÒéÊÊÅäÆ÷³öÏÖ´íÎó
¡¡¡¡TNS-00511: ÎÞ¼àÌýÆ÷
¡¡¡¡32-bit Windows Error: 61: Unknown error
¡¡¡¡LSNRCTL> start
¡¡¡¡Æô¶¯tnslsnr£ºÇëÉÔºò...
¡¡¡¡Failed to start service, error 3.
¡¡¡¡TNS-12536: TNS£º¿ÉÄÜ»á×è°*×÷
¡¡¡¡TNS-12560: TNS£ºÐÒéÊÊÅäÆ÷³öÏÖ´íÎó
¡¡¡¡TNS-00506: *×÷¿ÉÄÜ×èÈû
¡¡¡¡32-bit Windows Error: 997: Unknown error
¶þ¡¢½â¾ö
¡¡¡¡ÐÞ¸Ä listerner.ora(..ora92networkadmin),Îļþ,È· ......
TkprofÊÇÒ»¸öÓÃÓÚ·ÖÎöOracle¸ú×ÙÎļþ²¢ÇÒ²úÉúÒ»¸ö¸ü¼ÓÇåÎúºÏÀíµÄÊä³ö½á¹ûµÄ¿ÉÖ´Ðй¤¾ß¡£Èç¹ûÒ»¸öϵͳµÄÖ´ÐÐЧÂʱȽϵͣ¬Ò»¸ö±È½ÏºÃµÄ·½·¨ÊÇͨ¹ý¸ú×ÙÓû§µÄ»á»°²¢ÇÒʹÓÃTkprof¹¤¾ßʹÓÃÅÅÐò¹¦Äܸñʽ»¯Êä³ö£¬´Ó¶øÕÒ³öÓÐÎÊÌâµÄSQLÓï¾ä¡£
Ò». TKPROF ÃüÁîÓï·¨£º
TKPROF filename1, filename2 [ SORT = [ opion][,option] ]
[ PRINT = integer ]
[ AGGREGATE = [ YES | NO ] ]
[ INSERT = filename3 ]
[ SYS = [ YES | NO ] ]
[ [ TABLE = schema.table ] | [ EXPLAIN = user/password ] ]
[ RECORD = filename ]
Ïà¹Ø˵Ã÷£º
filename1 Ö¸¶¨µÄÊäÈëÎļþ£¬¿ÉÒÔÊǶà¸öÎļþÁªÆðÀ´¡£
Filename2 ¸ñʽ»¯Êä³öÎļþ¡£
SORT ÔÚ ......
1£®top
topÃüÁî¿ÉʵʱµØÏÔʾLinuxϵͳµÄ½ø³Ì¡¢CPU¡¢ÄÚ´æ¡¢¸ºÔصȵÄÐÅÏ¢¡£ËüÊÇÎÒÃÇÁ˽âϵͳÕûÌå״̬×îºÃµÄ¹¤¾ß¡£
topÃüÁîµÄÔËÐÐ״̬ÊÇÒ»¸öʵʱµÄÏÔʾ¹ý³Ì£¬ÎÒÃÇ¿ÉÔÚÕâ¸ö½çÃæ¼à¿ØϵͳÔËÐÐÇé¿ö¡£ÎÒÃÇ¿Éͨ¹ý¼¸¸ö°´¼üÀ´¿ØÖÆtopÃüÁÈç°´q¿ÉÍ˳ötopÃüÁî״̬£¬°´s¿ÉÊäÈëÐÅÏ¢µÄ¸üÐÂƵÂʵȡ£ÕâЩÃüÁî¿É°´h°ïÖú¼ü²éѯ¡£
2£®Ps
psÃüÁî¿É²éѯϵͳµÄ½ø³Ì״̬£¬³£ÓõÄÃüÁî²ÎÊýÊÇps -aux£¬¸ÃÃüÁî¿ÉÏÔʾËùÓÐÓû§µÄ½ø³Ì£¬Èç¹û½ø³ÌµÄÃüÁîÌ«³¤£¬ÔòÏÔʾµÄ½ø³ÌÐÅÏ¢»á²»È«¡£ÎÒÃÇ¿ÉÓÃps -auxwÃüÁîÀ´¼Ó³¤ÏÔʾ£¬w²ÎÊý¿É¶à¼Ó¼¸¸ö£¬×î¶à¿É¼ÓÈý¸ö£¬ÒÔÏÔʾ¸ü³¤µÄ½ø³ÌÐÅÏ¢¡£
3£®Kill
killÃüÁî¿ÉÖÕÖ¹½ø³Ì£¬ºó½Ó½ø³ÌºÅ¼´¿É¡£
4£®Free
free¿ÉÏÔʾϵͳµÄÄÚ´æʹÓÃÇé¿ö¡£-b¡¢-k¡¢-mÈý¸ö²ÎÊý±íʾÒÔbytes£¬kilobytesºÍmegabytesΪµ¥Î»ÏÔʾÄÚ´æµÄʹÓÃÇé¿ö¡£
5£®Vmstat
ʹÓÃvmstat 2 ÃüÁî¿Éÿ¸ô2ÃëÏÔʾһÐÐϵͳÐÅÏ¢£¬ÕâЩÐÅÏ¢°üÀ¨CPUÕ¼ÓÃЧ¡¢ÄÚ´æʹÓÃÇé¿öºÍ´ÅÅÌIOµÈ¡£Í¨¹ýËüÎÒÃÇ¿Éʵʱ¼à¿ØϵͳµÄ×ÊԴʹÓÃÇé¿ö£¬½øÐÐϵͳÓÅ»¯¡£
6£®sar
sar¹¤¾ß¿É°ïÎÒÃÇÊÕ¼¯¶¯Ì¬µÄϵͳÐÅÏ¢£¬ËüµÄ²ÎÊýºÜ·á¸»£¬¹¦ÄÜÇ¿´ó¡£sar¹¤¾ßµÄÌصãÊÇ¿Éͨ¹ý¼ÆÊýÆ÷ºÍ¼ÆÊý¼ä¸ôÀ´¶¨ÆÚ¡¢¶¨Á¿µØÊä³öϵͳ״̬ÐÅÏ¢¡£
7£®watch
wat ......
1£®top
topÃüÁî¿ÉʵʱµØÏÔʾLinuxϵͳµÄ½ø³Ì¡¢CPU¡¢ÄÚ´æ¡¢¸ºÔصȵÄÐÅÏ¢¡£ËüÊÇÎÒÃÇÁ˽âϵͳÕûÌå״̬×îºÃµÄ¹¤¾ß¡£
topÃüÁîµÄÔËÐÐ״̬ÊÇÒ»¸öʵʱµÄÏÔʾ¹ý³Ì£¬ÎÒÃÇ¿ÉÔÚÕâ¸ö½çÃæ¼à¿ØϵͳÔËÐÐÇé¿ö¡£ÎÒÃÇ¿Éͨ¹ý¼¸¸ö°´¼üÀ´¿ØÖÆtopÃüÁÈç°´q¿ÉÍ˳ötopÃüÁî״̬£¬°´s¿ÉÊäÈëÐÅÏ¢µÄ¸üÐÂƵÂʵȡ£ÕâЩÃüÁî¿É°´h°ïÖú¼ü²éѯ¡£
2£®Ps
psÃüÁî¿É²éѯϵͳµÄ½ø³Ì״̬£¬³£ÓõÄÃüÁî²ÎÊýÊÇps -aux£¬¸ÃÃüÁî¿ÉÏÔʾËùÓÐÓû§µÄ½ø³Ì£¬Èç¹û½ø³ÌµÄÃüÁîÌ«³¤£¬ÔòÏÔʾµÄ½ø³ÌÐÅÏ¢»á²»È«¡£ÎÒÃÇ¿ÉÓÃps -auxwÃüÁîÀ´¼Ó³¤ÏÔʾ£¬w²ÎÊý¿É¶à¼Ó¼¸¸ö£¬×î¶à¿É¼ÓÈý¸ö£¬ÒÔÏÔʾ¸ü³¤µÄ½ø³ÌÐÅÏ¢¡£
3£®Kill
killÃüÁî¿ÉÖÕÖ¹½ø³Ì£¬ºó½Ó½ø³ÌºÅ¼´¿É¡£
4£®Free
free¿ÉÏÔʾϵͳµÄÄÚ´æʹÓÃÇé¿ö¡£-b¡¢-k¡¢-mÈý¸ö²ÎÊý±íʾÒÔbytes£¬kilobytesºÍmegabytesΪµ¥Î»ÏÔʾÄÚ´æµÄʹÓÃÇé¿ö¡£
5£®Vmstat
ʹÓÃvmstat 2 ÃüÁî¿Éÿ¸ô2ÃëÏÔʾһÐÐϵͳÐÅÏ¢£¬ÕâЩÐÅÏ¢°üÀ¨CPUÕ¼ÓÃЧ¡¢ÄÚ´æʹÓÃÇé¿öºÍ´ÅÅÌIOµÈ¡£Í¨¹ýËüÎÒÃÇ¿Éʵʱ¼à¿ØϵͳµÄ×ÊԴʹÓÃÇé¿ö£¬½øÐÐϵͳÓÅ»¯¡£
6£®sar
sar¹¤¾ß¿É°ïÎÒÃÇÊÕ¼¯¶¯Ì¬µÄϵͳÐÅÏ¢£¬ËüµÄ²ÎÊýºÜ·á¸»£¬¹¦ÄÜÇ¿´ó¡£sar¹¤¾ßµÄÌصãÊÇ¿Éͨ¹ý¼ÆÊýÆ÷ºÍ¼ÆÊý¼ä¸ôÀ´¶¨ÆÚ¡¢¶¨Á¿µØÊä³öϵͳ״̬ÐÅÏ¢¡£
7£®watch
wat ......
MYSQLºÍORACLEµÄһЩ²Ù×÷Çø±ð
ÓкܶàÓ¦ÓÃÏîÄ¿, ¸ÕÆð²½µÄʱºòÓÃMYSQLÊý¾Ý¿â»ù±¾ÉÏÄÜʵÏÖ¸÷ÖÖ¹¦ÄÜÐèÇó£¬Ëæ×ÅÓ¦ÓÃÓû§µÄÔö¶à£¬Êý¾ÝÁ¿µÄÔö¼Ó£¬MYSQL½¥½¥µØ³öÏÖ²»¿°ÖظºµÄÇé¿ö£ºÁ¬½ÓºÜÂýÉõÖÁå´»ú£¬ÓÚÊǾÍÓаÑÊý¾Ý´ÓMYSQLǨµ½ORACLEµÄÐèÇó£¬Ó¦ÓóÌÐòÒ²ÒªÏàÓ¦×öһЩÐ޸ġ£±¾ÈË×ܽá³öÒÔϼ¸µã×¢ÒâÊÂÏϣÍû¶Ô´ó¼ÒÓÐËù°ïÖú¡£
1.×Ô¶¯Ôö³¤µÄÊý¾ÝÀàÐÍ´¦Àí
MYSQLÓÐ×Ô¶¯Ôö³¤µÄÊý¾ÝÀàÐÍ£¬²åÈë¼Ç¼ʱ²»ÓòÙ×÷´Ë×ֶΣ¬»á×Ô¶¯»ñµÃÊý¾ÝÖµ¡£ORACLEûÓÐ×Ô¶¯Ôö³¤µÄÊý¾ÝÀàÐÍ£¬ÐèÒª½¨Á¢Ò»¸ö×Ô¶¯Ôö³¤µÄÐòÁкţ¬²åÈë¼Ç¼ʱҪ°ÑÐòÁкŵÄÏÂÒ»¸öÖµ¸³ÓÚ´Ë×ֶΡ£
CREATE SEQUENCE ÐòÁкŵÄÃû³Æ (×îºÃÊDZíÃû+ÐòÁкűê¼Ç) INCREMENT BY 1 START WITH 1 MAXVALUE 99999 CYCLE NOCACHE;
ÆäÖÐ×î´óµÄÖµ°´×ֶεij¤¶ÈÀ´¶¨, Èç¹û¶¨ÒåµÄ×Ô¶¯Ôö³¤µÄÐòÁкŠNUMBER(6) , ×î´óֵΪ999999
INSERT Óï¾ä²åÈëÕâ¸ö×Ö¶ÎֵΪ: ÐòÁкŵÄÃû³Æ.NEXTVAL
2. µ¥ÒýºÅµÄ´¦Àí
MYSQLÀï¿ÉÒÔÓÃË«ÒýºÅ°üÆð×Ö·û´®£¬ORACLEÀïÖ»¿ÉÒÔÓõ¥ÒýºÅ°üÆð×Ö·û´®¡£ÔÚ²åÈëºÍÐÞ¸Ä×Ö·û´®Ç°±ØÐë×öµ¥ÒýºÅµÄÌæ»»£º°ÑËùÓгöÏÖµÄÒ»¸öµ¥ÒýºÅÌæ»»³ÉÁ½¸öµ¥ÒýºÅ¡£
3. ·Ò³µÄSQLÓï¾äµÄ´¦Àí
MYSQL´¦Àí·Ò³µÄSQLÓï¾ä±È½Ï¼òµ¥£¬ÓÃLIMIT ¿ªÊ¼Î»ÖÃ, ¼Ç¼¸öÊý£»PHPÀï» ......
MYSQLºÍORACLEµÄһЩ²Ù×÷Çø±ð
ÓкܶàÓ¦ÓÃÏîÄ¿, ¸ÕÆð²½µÄʱºòÓÃMYSQLÊý¾Ý¿â»ù±¾ÉÏÄÜʵÏÖ¸÷ÖÖ¹¦ÄÜÐèÇó£¬Ëæ×ÅÓ¦ÓÃÓû§µÄÔö¶à£¬Êý¾ÝÁ¿µÄÔö¼Ó£¬MYSQL½¥½¥µØ³öÏÖ²»¿°ÖظºµÄÇé¿ö£ºÁ¬½ÓºÜÂýÉõÖÁå´»ú£¬ÓÚÊǾÍÓаÑÊý¾Ý´ÓMYSQLǨµ½ORACLEµÄÐèÇó£¬Ó¦ÓóÌÐòÒ²ÒªÏàÓ¦×öһЩÐ޸ġ£±¾ÈË×ܽá³öÒÔϼ¸µã×¢ÒâÊÂÏϣÍû¶Ô´ó¼ÒÓÐËù°ïÖú¡£
1.×Ô¶¯Ôö³¤µÄÊý¾ÝÀàÐÍ´¦Àí
MYSQLÓÐ×Ô¶¯Ôö³¤µÄÊý¾ÝÀàÐÍ£¬²åÈë¼Ç¼ʱ²»ÓòÙ×÷´Ë×ֶΣ¬»á×Ô¶¯»ñµÃÊý¾ÝÖµ¡£ORACLEûÓÐ×Ô¶¯Ôö³¤µÄÊý¾ÝÀàÐÍ£¬ÐèÒª½¨Á¢Ò»¸ö×Ô¶¯Ôö³¤µÄÐòÁкţ¬²åÈë¼Ç¼ʱҪ°ÑÐòÁкŵÄÏÂÒ»¸öÖµ¸³ÓÚ´Ë×ֶΡ£
CREATE SEQUENCE ÐòÁкŵÄÃû³Æ (×îºÃÊDZíÃû+ÐòÁкűê¼Ç) INCREMENT BY 1 START WITH 1 MAXVALUE 99999 CYCLE NOCACHE;
ÆäÖÐ×î´óµÄÖµ°´×ֶεij¤¶ÈÀ´¶¨, Èç¹û¶¨ÒåµÄ×Ô¶¯Ôö³¤µÄÐòÁкŠNUMBER(6) , ×î´óֵΪ999999
INSERT Óï¾ä²åÈëÕâ¸ö×Ö¶ÎֵΪ: ÐòÁкŵÄÃû³Æ.NEXTVAL
2. µ¥ÒýºÅµÄ´¦Àí
MYSQLÀï¿ÉÒÔÓÃË«ÒýºÅ°üÆð×Ö·û´®£¬ORACLEÀïÖ»¿ÉÒÔÓõ¥ÒýºÅ°üÆð×Ö·û´®¡£ÔÚ²åÈëºÍÐÞ¸Ä×Ö·û´®Ç°±ØÐë×öµ¥ÒýºÅµÄÌæ»»£º°ÑËùÓгöÏÖµÄÒ»¸öµ¥ÒýºÅÌæ»»³ÉÁ½¸öµ¥ÒýºÅ¡£
3. ·Ò³µÄSQLÓï¾äµÄ´¦Àí
MYSQL´¦Àí·Ò³µÄSQLÓï¾ä±È½Ï¼òµ¥£¬ÓÃLIMIT ¿ªÊ¼Î»ÖÃ, ¼Ç¼¸öÊý£»PHPÀï» ......