Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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²éѯ»º´æµÄÄÚ´æËéƬ

query_cache_min_res_unit   ²éѯ»º´æ·ÖÅäµÄ×îС¿éµÄ´óС(×Ö½Ú)
query_alloc_block_size    Ϊ²éѯ·ÖÎöºÍÖ´Ðйý³ÌÖд´½¨µÄ¶ÔÏó·ÖÅäµÄÄÚ´æ¿é´óС
Qcache_free_blocks´ú±íÄÚ´æ×ÔÓÉ¿éµÄ¶àÉÙ£¬·´Ó³ÁËÄÚ´æËéƬµÄÇé¿ö
==========================
1£©µ±²éѯ½øÐеÄʱºò£¬Mysql°Ñ²éѯ½á¹û±£´æÔÚqurey ......

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


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

mysql×Ö·û¼¯ÎÊÌâ

MySQLµÄ×Ö·û¼¯Ö§³Ö(Character Set Support)ÓÐÁ½¸ö·½Ã棺
     ×Ö·û¼¯(Character set)ºÍÅÅÐò·½Ê½(Collation)¡£
¶ÔÓÚ×Ö·û¼¯µÄÖ§³Öϸ»¯µ½Ëĸö²ã´Î:
     ·þÎñÆ÷(server)£¬Êý¾Ý¿â(database)£¬Êý¾Ý±í(table)ºÍÁ¬½Ó(connection)¡£
1.MySQLĬÈÏ×Ö·û¼¯
  MySQL¶ÔÓÚ×Ö·û¼¯µÄ ......

MySQL ÊÂÎñ ´æ´¢¹ý³Ì ʵÀý

USE dxdb;
DELIMITER //
#»ñÈ¡Á÷Ë®ºÅ
DROP PROCEDURE IF EXISTS get_sid;
CREATE PROCEDURE get_sid(para_domain VARCHAR(20), out para_sid BIGINT UNSIGNED)
BEGIN
START TRANSACTION;
UPDATE t_sid SET sID=sID+1 WHERE cDomain=para_domain;
SELECT sID INTO para_sid from t_sid WHERE cDomain=para_domain;
......

ÈçºÎÐÞ¸Ämysql rootÃÜÂë

1¡¢±à¼­MySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ)ÅäÖÃÎļþ£º
windows»·¾³ÖУº%MySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ)_installdir%\my.ini¡¡//Ò»°ãÔÚMySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ)°²×°Ä¿Â¼ÏÂÓÐmy.ini¼´MySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ)µÄÅäÖÃÎļþ¡£
linux»·¾³ÖУº/etc/my.cnf
ÔÚ[MySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ)d]ÅäÖöÎÌí¼ÓÈçÏÂÒ»ÐУº
skip-grant-tables
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ