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

¸ßÐÔÄÜMYSQL¶ÁÊé±Ê¼Ç£ºMYSQL×¼±¸Óï¾ä

MYSQL4.1¼°¸ü¸ß°æ±¾Ö§³Ö·þÎñÆ÷¶Ë×¼±¸Óï¾ä(Prepared Statements), ËüʹÓÃÔöÇ¿µÄ¶þ½øÖÆ¿Í»§¶Ë/·þÎñÆ÷ЭÒéÔÚ¿Í»§¶ËºÍ·þÎñÆ÷Ö®¼ä¸ßЧµÄ·¢ËÍÊý¾Ý£¬¿ÉÒÔͨ¹ýÖ§³ÖÕâÖÖÐÐЭÒéµÄ±à³Ì¿âÀ´·ÃÎÊ×¼±¸Óï¾ä£¬ÁÐÈëMYSQL CAPI,MYSQL Connector/JºÍMYSQL Connector/NET ΪJAVAºÍ.NETÌṩÁËͬÑùµÄ·ÃÎʽӿڡ£ËüÒ²ÓÐSQLÓïÑԵķÃÎʽӿڡ£
´´½¨×¼±¸Óï¾äʱ£¬¿Í»§¶Ë¿â»áÏñ·þÎñÆ÷·¢ËÍÒ»¸öʵ¼Ê²éѯµÄÔ­ÐÍ£¬È»ºó·þÎñÆ÷¶Ô¸ÃÔ­ÐͽøÐнâÎöºÍ´¦Àí£¬½«²¿·ÖÓÅ»¯¹ýµÄÔ­Ðͱ£´æÆðÀ´£¬²¢ÇÒ¸ø¿Í»§¶Ë·µ»ØÒ»¸ö״̬¾ä±ú(State Handle) ¿Í»§¶Ë¿ÉÒÔͨ¹ý¶¨Òå״̬¾ä±úÖظ´µÄÖ´Ðвéѯ¡£
¿ÉÒÔ°´ÏÂÃæµÄ·½Ê½×¼±¸²éѯ£º
INSERT INTO  table(col1,col2,col3) VALUES(?,?,?);
MYSQLΪ׼±¸Óï¾äÌṩÁËSQLÓïÑÔ½Ó¿Ú¡£ÀýÈ磺
SET @sql = 'SELECT col1,col2,col3' from table where col1 = ?';
PREPARE stmt_fetch_actor from @sql;
SET @name = 'test';
EXECUTE smtm_fetch_actor USING @name;
DEALLOCATE PREPARE smtm_fetch_actor;
ÔÚMYSQL 5.0ÖпÉÒÔÔÚ´æ´¢¹ý³ÌÖÐʹÓÃ×¼±¸Óï¾ä¡£
×¼±¸Óï¾ä»á±È¶à´ÎÖ´ÐвéѯЧÂʸߺܶ࣬¾ßÌåÔ­ÒòÈçÏ£º
1.·þÎñÆ÷Ö»ÐèÒª½âÎöÒ»´Î²éѯ£¬Õâ½ÚÔ¼Á˽âÎöºÍÆäËû¿ªÏú
2.ÒòΪ·þÎñÆ÷»º´æÁËÒ»²¿·ÖÖ´Ðмƻ®£¬ËùÒÔËüÖ»ÐèÒªÖ´ÐÐijЩÓÅ»¯²½ÖèÒ»´Î¡£
ͨ¹ý¶þ½øÖÆ·¢ËͲÎÊý±Èͨ¹ýASCIIÂëÒª¿ìµÄ¶à£¬±ÈÈ磬ͨ¹ý¶þ½øÖÆ·¢ËÍDATEÀàÐ͵IJÎÊýÖ»ÐèÒª3×Ö½Ú£¬µ«Í¨¹ýASCIIÂë·¢ËÍÐèÒª10¸ö×Ö½Ú¡£½â¾öµÄЧ¹û¶ÔÓÚBLOBºÍTEXTÀàÐÍ×îΪÏÔÖø¡£ÒòΪËûÃÇ¿ÉÒԳɿéµÄ·¢ËÍ¡£¶ø²»ÊÇÒ»¸ö¸öµÄ·¢ËÍ¡£¶þ½øÖÆЭÒéÒ²°ï¿Í»§¶Ë½ÚÔ¼ÁËÄڴ棬ͬʱ¼õÉÙÁËÍøÂ翪ÏúºÍÊý¾Ý´Ó±¾ÉíµÄÀàÐÍת»»Îª·Ç¶þ½øÖÆЭÒéµÄ¿ªÏú¡£
3.Õû¸ö²éѯ²»»á±»·¢Ë͵½·þÎñÆ÷¡£Ö»ÓвÎÊý²Å»á±»·¢ËÍ£¬¼õÉÙÁËÍøÂçÁ÷Á¿¡£
4.MYSQLÖ±½Ó°É²ÎÊý±£´æÔÚ·þÎñÆ÷µÄ»º³åÇøÄÚ£¬²»ÐèÒªÔÚÄÚ´æÖе½´¦¿½±´Êý¾Ý¡£
5.×¼±¸Óï¾ä¶ÔÓÚ°²È«ÐÔÒ²Óкô¦£¬Ëü²»ÐèÒªÔÚÓ¦ÓóÌÐòÖжÔÖµ½øÐÐתÒƺͼÓÒýºÅ¡£Õâ¸ü¼Ó·½±ã£¬²¢ÇÒ¼õÉÙÁËSQLÔâÊÜ×¢Èë¹¥»÷ºÍÆäËû¹¥»÷µÄ¿ÉÄÜ(ÓÀÔ¶Ò²²»ÄÜÐÅÈÎÓû§µÄÊäÈ룬¼´Ê¹Ê¹ÓÃ×¼±¸Óï¾äÒ²²»ÄÜ)
Ö»ÓÐ×¼±¸Óï¾äÄÜʹÓöþ½øÖÆЭÒ飬ʹÓÃÆÕͨµÄMSYQL_QUERY()º¯ÊýÌá½»²éѯ²»»áʹÓöþ½øÖÆЭÒ飬
×¼±¸Óï¾äµÄ¾ÖÏÞ£º
1.×¼±¸Óï¾äÖ»Õë¶ÔÒ»¸öÁ¬½Ó£¬ËùÒÔÁíÍâµÄÁ¬½Ó²»ÄÜʹÓÃͬÑùµÄ¾ä±ú£¬´¦ÓÚͬÑùµÄÔ­Òò£¬Ò»¸öÏȶϿªÔÙÖØÐÂÁ¬½ÓµÄ¿Í»§¶Ë»á¶ªÊ§¾ä±ú(Á¬½Ó³Ø»î³ÖÐøÁ¬½Ó»á¼õÇáÕâ¸öÎÊÌâ)
2.×¼±¸Óï¾ä²»ÄÜʹÓÃMYSQL5.0ÒÔÇ°µÄ°æ±¾»º´æ
3.ʹÓÃ×¼±¸Óï¾ä²¢²»×ÜÊǸßЧ£¬Èç¹ûֻʹÓÃÒ»´Î×¼±¸Ó


Ïà¹ØÎĵµ£º

mysqlÃüÁîÐв»Ö´ÐкÍÃüÁîÐÐÖÐÎÄÂÒÂëµÄ½â¾ö


1£ºMysql ÃüÁî²»¿ÉÒÔÖ´ÐÐ
Ô­Òò £ººÇºÇ ±ÈÈç show databases µÄÃüÁî £¬Ö´ÐÐÍêÖ®ºó ɶҲûÓÐ £¬×Ðϸ ÕÒÁËÔ­Òò £¬Oh my god  ÉÙÁË ·ÖºÅ¡£
Ӧд³É£ºshow databases;
2£ºÃüÁîÐÐÖÐÎÄÂÒÂëÎÊÌâ
ÏÖÏó£ºmysqlµÄĬÈϱàÂëÉèÖÃΪutf-8£¬Ò³ÃæÒÔutf-8µÄ±àÂ뷽ʽдÈëµ½Êý¾Ý¿â¡£Óù¤¾ß²é¿´Ò»ÇÐÕý³££¬µ«´ÓmysqlµÄÃüÁîÐжÁÊý¾Ý³öÀ´× ......

mysqlϵķÖÒ³´æ´¢¹ý³Ì

CREATE PROCEDURE pro_page(
 in _sql varchar(1000),
 in _order varchar(1000),
 in _pagecurrent int,
 in _pagesize int
)
BEGIN
 if _pagesize<=1 then
  set _pagesize=20;
 end if;
 if _pagecurrent < 1 then
  set _pagecurrent = 1;
&n ......

ÈçºÎÐÞ¸ÄSQLPLUSÌáʾ·ûºÍmysqlÌáʾ·û

×÷Õß Ð¡ºÉ||¡¾×ªÔØʱÇëÎñ±ØÒÔ³¬Á´½ÓÐÎʽ±êÃ÷ÎÄÕÂԭʼ³ö´¦ºÍ×÷ÕßÐÅÏ¢¡¿
· ÓÀ¾ÃÁ´½Ó: http://www.oracleblog.cn/useful-script/prompt-of-sqlplus/
misc@ORALOCAL(192.168.0.49)>
Èç¹ûÄãÒ²ÏëºÍÎÒÒ»Ñù£¬ÔÚsqlplusµÇ¼Êý¾Ý¿âµÄʱºò£¬ÄÜÌáʾ²»ÉÙÏñÉÏÃæÕâÑùÏêϸµÇ¼µÄÐÅÏ¢£º
1.µÇ¼µÄÓû§Ãû¡£µ±ÄãµÄÊý¾Ý¿âÖÐÓжà¸ö ......

mysqlÖÐINSTRº¯ÊýµÄÓ÷¨

mysqlÖÐINSTRº¯ÊýµÄÓ÷¨
INSTR(×Ö¶ÎÃû, ×Ö·û´®)
Õâ¸öº¯Êý·µ»Ø×Ö·û´®ÔÚijһ¸ö×ֶεÄÄÚÈÝÖеÄλÖÃ, ûÓÐÕÒµ½×Ö·û´®·µ»Ø0£¬·ñÔò·µ»ØλÖ㨴Ó1¿ªÊ¼£©
SELECT * from tblTopic ORDER BY INSTR( topicTitle, 'ha' ) > 0 DESC
SELECT INSTR( topicTitle, 'ha' ) from tblTopic
mysqlÖÐʹÓÃinstrÅäºÏINÅÅÐò
½«instr½á¹û×÷Î ......

ÓÅ»¯MySQLÊý¾Ý¿âÐÔÄܵļ¸¸öºÃ·½·¨

1¡¢Ñ¡È¡×îÊÊÓõÄ×Ö¶ÎÊôÐÔ
¡¡¡¡MySQL¿ÉÒԺܺõÄÖ§³Ö´óÊý¾ÝÁ¿µÄ´æÈ¡£¬µ«ÊÇÒ»°ã˵À´£¬Êý¾Ý¿âÖеıíԽС£¬ÔÚËüÉÏÃæÖ´ÐеIJéѯҲ¾Í»áÔ½¿ì¡£Òò´Ë£¬ÔÚ´´½¨±íµÄʱºò£¬ÎªÁË»ñµÃ¸üºÃµÄÐÔÄÜ£¬ÎÒÃÇ¿ÉÒÔ½«±íÖÐ×ֶεĿí¶ÈÉèµÃ¾¡¿ÉÄÜС¡£ÀýÈ磬ÔÚ¶¨ÒåÓÊÕþ±àÂëÕâ¸ö×Ö¶Îʱ£¬Èç¹û½«ÆäÉèÖÃΪCHAR(255),ÏÔÈ»¸øÊý¾Ý¿âÔö¼ÓÁ˲»±ØÒªµÄ¿Õ¼ä£¬ÉõÖÁÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ