MYSQL ´¥·¢Æ÷
´¥·¢Æ÷ÔÚmysqlÖÐÓ¦ÓõIJ»¶à,ËüÊÇÔÚmysql5ÒÔÉϲſªÊ¼Ö§³ÖµÄ,²»Ö§³Ö²»´ú±íËü²»ÖØÒª,Ê×ÏÈÁ˽âÒ»ÏÂʲôÊÇ´¥·¢Æ÷.´¥·¢Æ÷ÊÇÔÚÊý¾Ý¿âÖÐΪÏìÓ¦Ò»¸öÌØÊâ±í¸ñÖеÄijЩʼþ¶ø×Ô¶¯Ö´ÐеijÌÐò´úÂë¡£(Wikipedia)˵µÃ¼òµ¥Ò»Ð©£¬ËüÊÇÔÚÒ»¸öÌØÊâµÄÊý¾Ý¿âʼþ£¬ÈçINSERT»òDELETE·¢Éúʱ£¬×Ô¶¯¼¤»îµÄÒ»¶Î´úÂë¡£´¥·¢Æ÷¿É·½±ãµØÓÃÓÚÈÕÖ¾¼Ç¼¡¢¶Ôµ¥¸ö±í¸ñµ½ÆäËûÁ´½Óʽ±í¸ñ½øÐÐ×Ô¶¯µÄ“²ãµþʽ”¸ü¸Ä¡¢»ò±£Ö¤¶Ô±í¸ñ¹Øϵ½øÐÐ×Ô¶¯¸üС£µ±Ò»¸öÐÂÕûÊýÖµÔö¼Óµ½Êý¾Ý¿âÓòÖÐʱ£¬×Ô¶¯¸üÐÂÔËÐеÄ×ÜÊýµÄ´úÂë¶ÎÊÇÒ»¸ö´¥·¢Æ÷¡£×Ô¶¯¼Ç¼¶ÔÒ»¸öÌØÊâÊý¾Ý¿â±í¸ñËù×÷¸ü¸ÄµÄSQLÃüÁî¿éÒ²ÊÇÒ»¸ö´¥·¢Æ÷ʵÀý¡£
´¥·¢Æ÷ÊÇMySQL 5.xµÄй¦ÄÜ£¬Ëæ×Å5.x´úÂëÊ÷а汾µÄ³öÏÖ£¬ÕâÒ»¹¦ÄÜÒ²Ö𽥵õ½¸ÄÉÆ¡£ÔÚ±¾ÎÄÖУ¬ÎÒ½«¼òµ¥½éÉÜÈçºÎ¶¨Ò岢ʹÓô¥·¢Æ÷£¬²é¿´´¥·¢Æ÷״̬£¬²¢ÈçºÎÔÚʹÓÃÍê±Ïºóɾ³ý´¥·¢Æ÷¡£ÎÒ»¹½«ÎªÄãչʾһ¸ö´¥·¢Æ÷ÔÚÏÖʵÊÀ½çÖеÄÓ¦ÓÃʵÀý£¬²¢¼ìÑéËü¶ÔÊý¾Ý¿â¼Ç¼µÄ¸Ä±ä¡£
Àý×Ó
ͨ¹ý¼òµ¥£¨ËäÈ»ÊÇÈËΪµÄ£©ÊµÀýÀ´ËµÃ÷ÊÇÁ˽âMySQL´¥·¢Æ÷Ó¦ÓõÄ×î¼Ñ°ì·¨¡£Ê×ÏÈÎÒÃǽ¨Á¢Á½¸öµ¥ÓòµÄ±í¸ñ¡£Ò»¸ö±í¸ñÖÐΪÐÕÃûÁÐ±í£¨±í¸ñÃû£ºdata£©£¬ÁíÒ»¸ö±í¸ñÖÐÊÇËù²åÈë×Ö·ûµÄ×Ö·ûÊý£¨±í¸ñÃû£ºchars£©¡£ÎÒÏ£ÍûÔÚdata±í¸ñÖж¨ÒåÒ»¸ö´¥·¢Æ÷£¬Ã¿´ÎÔÚÆäÖвåÈëÒ»¸öÐÂÐÕÃûʱ£¬chars±í¸ñÖÐÔËÐеÄ×ÜÊý¾Í»á¸ù¾ÝвåÈë¼Ç¼µÄ×Ö·ûÊýÄ¿½øÐÐ×Ô¶¯¸üС£
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
mysql> CREATE TABLE data (name VARCHAR(255));
Query OK, 0 rows affected (0.09 sec)
mysql> CREATE TABLE chars (count INT(10));
Query OK, 0 rows affected (0.07 sec)
mysql> INSERT INTO chars (count) VALUES (0);
Query OK, 1 row affected (0.00 sec)
mysql> CREATE TRIGGER t1 AFTER INSERT ON
data FOR EACH ROW UPDATE chars SET count = count + CHAR_LENGTH(NEW.name);
Query OK, 0 rows affected (0.01 sec)
Àí½âÉÏÃæ´úÂëµÄ¹Ø¼üÔÚÓÚCREATE TRIGGERÃüÁËü±»ÓÃÀ´¶¨ÒåÒ»¸öд¥·¢Æ÷¡£Õâ¸öÃüÁÁ¢Ò»¸öд¥·¢Æ÷£¬¼Ù¶¨µÄÃû³ÆΪt1£¬Ã¿´ÎÓÐÒ»¸öмǼ²åÈëµ½data±í¸ñÖÐʱ£¬t1¾Í±»¼¤»î¡£
ÔÚÕâ¸ö´¥·¢Æ÷ÖÐÓÐÁ½¸öÖØÒªµÄ×Ӿ䣺
AFTER INSERT×Ó¾ä±íÃ÷´¥·¢Æ÷ÔÚмǼ²åÈëdata±í¸ñºó¼¤»î¡£
UPDATE chars SET count = count + CHAR_LENGTH(NEW.name)×Ó¾ä±íʾ´¥·¢Æ÷¼¤»îºóÖ´ÐеÄSQLÃüÁî¡£ÔÚ±¾ÀýÖУ¬¸ÃÃüÁî±íÃ÷ÓÃвåÈëµÄdata.nameÓòµÄ×Ö·ûÊýÀ´¸üÐÂchars.countÀ¸¡£ÕâÒ»ÐÅÏ¢¿Éͨ¹ýÄÚÖõÄMySQLº¯ÊýCHAR_LENGTH()»ñµÃ¡£
·Å
Ïà¹ØÎĵµ£º
Ô¶³ÌÁ¬½ÓÁíһ̨µçÄÔµÄmysqlµÄÊý¾Ý¿âʱ£¬Èç¹ûÁ¬½Ó²»ÉÏ£¬Õâʱºò¾ÍÒªÔÚ±»Á¬½ÓµÄµçÄÔÉÏÖ´ÐÐÒÔÏÂÃüÁ
ÔÒò£ºÊÇûÓиøµÇ¼Óû§ÃûÉèÖÃÔ¶³ÌÖ÷»úµÇ¼µÄȨÏÞ
1¡£µÇ¼mysql £º
Ö´ÐУºmysql -u root -p
2¡£ÐÞ¸Ä MySQL Êý¾Ý¿âÖÐ user ±íÖÐ ¶ÔÓ¦Óû§ÃûµÄ Host ×ֶΣ¬½« localhost ¸ÄΪ %
Ö´ÐУºuse mysql;
ÔÙÖ´ÐУºupd ......
MySQLÓï¾äÓÅ»¯µÄÔÔò
1¡¢Ê¹ÓÃË÷ÒýÀ´¸ü¿ìµØ±éÀú±í¡£
¡¡¡¡È±Ê¡Çé¿öϽ¨Á¢µÄË÷ÒýÊÇ·ÇȺ¼¯Ë÷Òý£¬µ«ÓÐʱËü²¢²»ÊÇ×î¼ÑµÄ¡£ÔÚ·ÇȺ¼¯Ë÷ÒýÏ£¬Êý¾ÝÔÚÎïÀíÉÏËæ»ú´æ·ÅÔÚÊý¾ÝÒ³ÉÏ¡£ºÏÀíµÄË÷ÒýÉè¼ÆÒª½¨Á¢ÔÚ¶Ô¸÷ÖÖ²éѯµÄ·ÖÎöºÍÔ¤²âÉÏ¡£Ò»°ãÀ´Ëµ£º
¡¡¡¡a.ÓдóÁ¿Öظ´Öµ¡¢ÇÒ¾³£Óз¶Î§²éѯ£¨ > ,< ......
Ò». ÉèÖò½Ö裺1¡¢ÓÒ¼üµã»÷ÎҵĵçÄÔ£¬Ñ¡ÔñÊôÐÔ£¨¼ûͼ-1£©
1¡¢µã»÷¸ß¼¶£¬ÔÚ¶Ô»°¿òµÄϲ¿µã»÷»·¾³±äÁ¿
3¡¢ÔÚϵͳ±äÁ¿¶Ô»°¿òÖУ¬µã»÷н¨½øÐÐÉèÖÃ.
±äÁ¿Ãû£ºJAVA_HOME
±äÁ¿Öµ£ºC:\Program Files\Java\jdk1.6.0_05£¨ÔÚ´ËʹÓõÄÊÇĬÈÏ°²×°Â·¾¶£©
ϵͳ±äÁ¿->±à¼->±ä ......
Èí¼þ°æ±¾:
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£¬´ËʱÎÞÐèÊäÈëÃÜÂë ......