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

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Àﻹ¿ÉÒÔÓÃSEEK¶¨Î»µ½½á¹û¼¯µÄλÖá£ORACLE´¦Àí·­Ò³µÄSQLÓï¾ä¾Í±È½Ï·±ËöÁË¡£Ã¿¸ö½á¹û¼¯Ö»ÓÐÒ»¸öROWNUM×ֶαêÃ÷ËüµÄλÖÃ, ²¢ÇÒÖ»ÄÜÓÃROWNUM<100, ²»ÄÜÓÃROWNUM>80¡£
ÒÔÏÂÊǾ­¹ý·ÖÎöºó½ÏºÃµÄÁ½ÖÖORACLE·­Ò³SQLÓï¾ä( IDÊÇΨһ¹Ø¼ü×ÖµÄ×Ö¶ÎÃû )£º
Óï¾äÒ»£º
SELECT ID, [FIELD_NAME,...] from TABLE_NAME WHERE ID IN ( SELECT ID from (SELECT ROWNUM AS NUMROW, ID from TABLE_NAME WHERE Ìõ¼þ1 ORDER BY Ìõ¼þ2) WHERE NUMROW £¾ 80 AND NUMROW £¼ 100 ) ORDER BY Ìõ¼þ3;
Óï¾ä¶þ£º
SELECT * from (( SELECT ROWNUM AS NUMROW, c.* from (select [FIELD_NAME,...] from TABLE_NAME WHERE Ìõ¼þ1 ORDER BY Ìõ¼þ2) c) WHERE NUMROW £¾ 80 AND NUMROW £¼ 100 ) ORDER BY Ìõ¼þ3;
4£® ³¤×Ö·û´®µÄ´¦Àí
³¤×Ö·û´®µÄ´¦ÀíORACLEÒ²ÓÐËüÌØÊâµÄµØ·½¡£INSERTºÍUPDATEʱ×î´ó¿É²Ù×÷µÄ×Ö·û´®³¤¶ÈСÓÚµÈÓÚ4000¸öµ¥×Ö½Ú, Èç¹ûÒª²åÈë¸ü³¤µÄ×Ö·û´®, Ç뿼ÂÇ×Ö¶ÎÓÃCLOBÀàÐÍ£¬·½·¨½èÓÃORACLEÀï×Ô´øµÄDBMS_LOB³ÌÐò°ü¡£²åÈëÐ޸ļǼǰһ¶¨Òª×ö½øÐзǿպͳ¤¶ÈÅжϣ¬²»ÄÜΪ¿ÕµÄ×Ö¶ÎÖµºÍ³¬³ö³¤¶È×Ö¶ÎÖµ¶¼Ó¦¸ÃÌá³ö¾¯¸æ,·µ»ØÉϴβÙ×÷¡£
5. ÈÕÆÚ×ֶεĴ¦Àí
MYSQLÈÕÆÚ×ֶηÖDATEºÍTIMEÁ½ÖÖ£¬ORACLEÈÕÆÚ×Ö¶ÎÖ»ÓÐDATE£¬°üº¬ÄêÔÂÈÕʱ·ÖÃ


Ïà¹ØÎĵµ£º

Oracle°´×Ö·û½ØÈ¡×Ö·û´®º¯Êý

ÊäÈë²ÎÊý£ºstr ——Òª½ØÈ¡µÄ×Ö·û´®,  ch——Òª²éÕÒµÄ×Ö·û´®
½ØÈ¡ch֮ǰ£¨²»°üÀ¨ch£©µÄ×Ö·û´®£º substr(str, 0, instr(str, ch) - 1)
½ØÈ¡chÖ®ºó£¨²»°üÀ¨ch£©µÄ×Ö·û´®£º substr(str, , instr(str, ch) + 1, length(str)) ......

OracleµÄÓÅ»¯Æ÷ÓÐÁ½ÖÖÓÅ»¯·½Ê½(¶þ)

15. /*+USE_CONCAT*/
¶Ô²éѯÖеÄWHEREºóÃæµÄORÌõ¼þ½øÐÐת»»ÎªUNION  ALLµÄ×éºÏ²éѯ. (㶮°¡,ÏÈ´æ×Å)
ÀýÈç:
select /*+use_concat */ * from emp where deptno=10 OR empno=7788;
Execution Plan
----------------------------------------------------------
   0      S ......

Oracle³£ÓÃÓï¾ä

--ÈçºÎÓÃgrade±íµÄ×ÊÁÏÈ¥¸üÐÂusertable±íµÄ×ÊÁÏ£¨ÓйØÁªµÄ×Ö¶Îuserid£©
 update usertable u set u.grade =
 (select g.grade from grade g where g.userid = u.userid);
 
--ÈçºÎʹ²éѯ½á¹û×Ö¶ÎÉú³ÉÐòºÅ
select rownum, t.* from sm_t_pad_new t
--ÈçºÎ¿ìËÙ×öÒ»¸öºÍÔ­±íÒ»ÑùµÄ±¸·Ý±í
 create ......

Ó¦Ó÷ÃÎÊMysqlÓöµ½µÄÁ¬½ÓÎÊÌâ

×î½üÔÚ×öÒ»¸öСÏîÄ¿£¬¿ª·¢»·¾³£ºÊý¾Ý¿âmysql5.0£¬·þÎñÆ÷Tomcat5.5¡£ÏîÄ¿´ò³Éwar²¿ÊðÔÚtomcatÉÏÖ®ºó£¬Í¨¹ýÓ¦ÓýøÐвéѯ²Ù×÷£¬Èç¹û²Ù×÷¹ýÓÚƵ·±£¬ºǫ́»áÅ×ÈçÏÂÒì³££º
javax.servlet.ServletException: Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [08S01]; error co ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ