MySQL´¥·¢Æ÷½â¾ö·½°¸Àú³Ì
×î½ü£¬ÏîÄ¿ÖÐÓõ½mysql£¬ÓÉÓÚÊý¾ÝÁ¿·Ç³£´ó£¬Ã¿ÌìµÄÊý¾ÝÁ¿ÔÚ°ÙÍò¼¶£¬¿¼Âǵ½mysqlÊý¾Ý¿â´¦ÀíÐÔÄÜÒÔ¼°Êý¾ÝÊôÐÔ£¬¾ö¶¨±£´æ×ã¹»¶àµÄ²éѯÊý¾Ý¼´¿É£¬¾àµ±Ç°Ê±¼ä×î¾ÃÔ¶µÄÊý¾ÝÖ±½Óɾ³ý£¬ÎÞÐè½øÐб¸·Ý¡£
Í·ÄÔÖÐð³öµÄµÚÒ»¸öÏë·¨¾ÍÊÇ£¬ÄÜ·ñÀûÓÃmysqlÖеĴ¥·¢Æ÷£¬¼ì²éÊý¾Ý±í´óС£¬Èç¹û³¬¹ýÔ¤É賤¶È£¬Ôòɾ³ý²¿·ÖÊý¾Ý¡£
CREATE TRIGGER tg AFTER INSERT ON traffic_info
FOR EACH ROW BEGIN
...
DELETE from traffic_info WHERE time <= "..."
...
END;
Ö´Ðкó³öÏÖÈçÏ´íÎó£º
ERROR 1442 (HY000): Can't update table 'traffic_info' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
ÔÀ´£¬Ä¿Ç°MySQL´¥·¢Æ÷»¹²»Ö§³Öɾ³ý´¥·¢Æ÷ËùÔڵıíµÄÊý¾Ý£¬ok£¬ÎÒÔʼµÄÏë·¨ÊÇÿ¸öÊý¾Ý±í×Ô¼º¹ÜÀí±í´óС£¬ÏÖÔÚ¿´À´ÊÇÐв»Í¨ÁË¡£
µÚ¶þ¸öÏë·¨ÊǸɴàÓô洢¹ý³ÌµÃÁË£¬ÊÖ¶¯µ÷Óô洢¹ý³ÌÀ´¸üÐÂËùÓбíµÄ´óС£¬¿¼Âǵ½Êý¾Ý±íºÜ¶à£¬ÏëÐÒé¸ö½ÓÊÜÊý¾Ý±íÃûΪ²ÎÊýµÄ´æ´¢¹ý³Ì£º
CREATE PROCEDURE P(IN table_name VARCHAR(50)£¬ IN max_count INT)
READS SQL DATA
BEGIN
...
SELECT COUNT(1) from table_name
...
END;
ÕâÖÖ×ö·¨Ðв»Í¨£¬mysql»á½«“table_name”×Ö·û´®×÷Ϊ±íÃû£¬ËÑË÷ºó·¢ÏÖ£¬ÐèÒªÓõ½mysqlÐÂÌØÐÔprepare£¬²»¹ýÐèҪעÒâµÄÊÇ£¬¾ÍËãÊÇÀûÓÃprepare£¬»¹ÊÇÎÞ·¨Ö±½Ó´«ÈëÊý¾Ý±íÃû£¬ÐèÒªÀûÓÃCONCATÊÂÏÈÁ¬½Ó²éѯ×Ö·û´®£º
CREATE PROCEDURE P(IN table_name VARCHAR(50), IN max_count INT)
READS SQL DATA
BEGIN
...
SET @query_str = CONCAT("SELECT COUNT(1) from ", table_name);
PREPARE stmt from @query_str
EXECUTE stmt;
...
END;
×ÜËãÊÇËÍÁËÒ»¿ÚÆø£¬¿ÉÊÇÓÖ·¢ÏÖ£¬ÎÒÐèÒªÔÚ´æ´¢¹ý³ÌÖж¯Ì¬»ñÈ¡PREPARE²éѯµÄ·µ»Ø½á¹û£¬µ«ÊÇ£¬Ä¿Ç°mysql»¹ÎÞ·¨×öµ½ÕâÒ»µã£¬ÕæÊÇÈÃÈËʧÍû£¬¿´À´Ö»ÄÜÁíÃÙËü;ÁË……
ʱ¼ä²Ö´Ù£¬½ñÊÇΪ¼Ç
Ïà¹ØÎĵµ£º
Èí¼þ°æ±¾:
php-5.2.13-Win32
apache_2.2.9-win32-x86-no_ssl-r2.msi(×¢Ò⣺APACHE 2.2.X°æ±¾ÒÔÉÏÒªÔö¼Ó²å¼þ²ÅÖ§³ÖPHP 5µÄ)
mysql-5.1.44-win32.msi
ÏÈ×°µÄphp5,Ö±½Ó½âѹÎļþµ½C:\php(°²×°µ½ÄÄÀï²¢²»»áÓÐÓ°Ï죬ƾ¸öÈËϲºÅ£¬±¾ÎÄÖеÄËùÓз¾¶¶¼ÒÔÎҵݲװ·¾¶£¬Çë´ó¼ÒÔÚ×Ô¼ºµÄ»úÆ÷ÉÏ°²×°µÄʱºò×¢ÒâÐÞ¸ÄΪ×Ô¼ºµÄ·¾¶)
½Ó× ......
Èç¹ûÍü¼ÇmysqlµÄÃÜÂë,¿ÉÒÔÓÃÒÔϵķ½Ê½½øÐÐÐÞ¸Ä:
ÎÒÓõÄmysqlÊÇ5.1µÄserver
ÔÚwindowsÏ£º
´ò¿ªÃüÁîÐд°¿Ú£¬Í£Ö¹mysql·þÎñ£ºNet stop mysql
µ½mysqlµÄ°²×°Â·¾¶Æô¶¯mysql£¬ÔÚbinĿ¼ÏÂʹÓÃmysqld.exeÆô¶¯£¬ÔÚÃüÁîÐд°¿ÚÖ´ÐУºmysqld --skip-grant-tables
È»ºóÁíÍâ´ò¿ªÒ»¸öÃüÈëÁîÐд°¿Ú£¬Ö´ÐÐmysql£¬´ËʱÎÞÐèÊäÈëÃÜÂë ......
µÚÒ»²½£¬ÏÂÔØMysqlµÄJDBCÇý¶¯³ÌÐò£¬ÃûΪconnectorJ¡£ÏÂÔØÍøÖ·£ºhttp://dev.mysql.com/downloads/connector/j/
½âѹËõzipÎļþºó£¬½«Îļþmysql-connector-java-5.1.12-bin.jarµ½Ä¿Â¼d:\Software\MySQL\MySQL Server 5.1\jdbcdriver\ÖÐ
µÚ¶þ²½£¬ÐÞ¸ÄÎļþd:\Software\bea\WebLogic 9.23\user_projects\domains\MyDomain\bin\s ......
1 MYSQLÖеÄ×Ö·û¼¯¸ÅÄî
MysqlµÄ×Ö·û¼¯ÀïÓÐÁ½¸ö¸ÅÄһ¸öÊÇ"Character set£¨×Ö·û¼¯£©"£¬ÁíÒ»¸öÊÇ"Collations"¡£
1.1 Collations
Collations·³ÉÖÐÎÄÊÇ"УÑé"£¬ÔÚÍøÒ³¿ª·¢µÄ¹ý³ÌÖУ¬Õâ¸ö´Ê»ã£¬Ö»ÔÚMysqlÀïʹÓã¬Ö÷Òª×÷ÓÃÊÇÖ¸µ¼Mysql¶Ô×Ö·ûµÄ±È½Ï£¬±ÈÈ磬 ASCII×Ö·û¼¯ÀCol ......
Another Look at MySQL 5.1's SQL Diagnostic Tools
http://dev.mysql.com/tech-resources/articles/mysql_51_diagnostic_tools.html Êý¾Ý¿âµÄÐÔÄܾö¶¨ÒòËØ£º
£¨1£©Êý¾Ý¿âµÄÉè¼Æ
£¨2£©SQL´úÂë ¿ÉÒÔÓÃÒÔϼ¸ÖÖ·½·¨À´½â¾öһЩÐÔÄÜÎÊÌ⣺
£¨1£©Ë÷Òý
£¨2£©Ë®Æ½·ÖÇø
£¨3£©ÁÐÊÊÓ¦µÄ±í
colum ......