MySQLÖÐselect * for updateËø±íµÄÎÊÌâ
select * for updateËø±íµÄÎÊÌâ
ÓÉÓÚInnoDBÔ¤ÉèÊÇRow-Level Lock£¬ËùÒÔÖ»ÓС¸Ã÷È·¡¹µÄÖ¸¶¨Ö÷¼ü£¬MySQL²Å»áÖ´ÐÐRow lock (Ö»Ëøס±»Ñ¡È¡µÄ×ÊÁÏÀý) £¬·ñÔòMySQL½«»áÖ´ÐÐTable Lock (½«Õû¸ö×ÊÁÏ±íµ¥¸øËøס)¡£
¾Ù¸öÀý×Ó:
¼ÙÉèÓиö±íµ¥products £¬ÀïÃæÓÐid¸úname¶þ¸öÀ¸Î»£¬idÊÇÖ÷¼ü¡£
Àý1: (Ã÷È·Ö¸¶¨Ö÷¼ü£¬²¢ÇÒÓд˱Ê×ÊÁÏ£¬row lock)
SELECT * from products WHERE id='3' FOR UPDATE;
Àý2: (Ã÷È·Ö¸¶¨Ö÷¼ü£¬Èô²éÎ޴˱Ê×ÊÁÏ£¬ÎÞlock)
SELECT * from products WHERE id='-1' FOR UPDATE;
Àý2: (ÎÞÖ÷¼ü£¬table lock)
SELECT * from products WHERE name='Mouse' FOR UPDATE;
Àý3: (Ö÷¼ü²»Ã÷È·£¬table lock)
SELECT * from products WHERE id<>'3' FOR UPDATE;
Àý4: (Ö÷¼ü²»Ã÷È·£¬table lock)
SELECT * from products WHERE id LIKE '3' FOR UPDATE;
×¢1: FOR UPDATE½öÊÊÓÃÓÚInnoDB£¬ÇÒ±ØÐëÔÚ½»Ò×Çø¿é(BEGIN/COMMIT)ÖвÅÄÜÉúЧ¡£
×¢2: Òª²âÊÔ
Ëø¶¨µÄ×´¿ö£¬¿ÉÒÔÀûÓÃMySQLµÄCommand Mode £¬¿ª¶þ¸öÊÓ´°À´×ö²âÊÔ¡£
Ïà¹ØÎĵµ£º
Apache¹Ù·½ÏÂÔصØÖ·£ºapache_2.0.55-win32-x86-no_ssl.msi£¬¸ü¶à°æ±¾ÔÚÕâÀ
php¹Ù·½ÏÂÔصØÖ·£ºphp-5.0.5-Win32.zip£¬¸ü¶à¾µÏñÏÂÔصØÖ·£¬¸ü¶à°æ±¾ÏÂÔØ£»
mysql¹Ù·½ÏÂÔصØÖ·£ºmysql-4.1.14-win32.zip£¬¸ü¶à¾µÏñÏÂÔصØÖ·£¬¸ü¶à°æ±¾ÏÂÔØ¡£
ApacheµÄÅäÖãº
ÎÒÒ»¿ªÊ¼Ôõô¸ã¶¼²»ºÃ£¬ÎÒÉÏÍøÕÒ£¬ÓеÄ˵ÊÇiisµÄÎÊÌ⣬ÓеÄ˵ÊÇ ......
ÓÃÔÚSELECTºÍWHERE×Ó¾äµÄº¯Êý
--------------------------------------------------------------
1 ·Ö×麯Êý
( ... ) À¨ºÅ¡£Ê¹ÓÃËüÃÇÀ´Ç¿ÖÆÔÚÒ»¸ö±í´ïʽµÄ¼ÆËã˳Ðò¡£
--------------------------------------------------------------
2 ³£ÓõÄËãÊõÔËËã
£¨+ - * /£©
Ò»°ãµÄË ......
Mysql my.ini ÅäÖÃÎļþÏê½â
#BEGIN CONFIG INFO
#DESCR: 4GB RAM, ֻʹÓÃInnoDB, ACID, ÉÙÁ¿µÄÁ¬½Ó, ¶ÓÁиºÔØ´ó
#TYPE: SYSTEM
#END CONFIG INFO
#
# ´ËmysqlÅäÖÃÎļþÀý×ÓÕë¶Ô4GÄÚ´æ
# Ö÷ҪʹÓÃINNODB
#´¦Àí¸´ÔÓ¶ÓÁв¢ÇÒÁ¬½ÓÊýÁ¿½ÏÉÙµÄmysql·þÎñÆ÷
#
# ½«´ËÎļþ¸´ÖƵ½/etc/my.cnf ×÷Ϊȫ¾ÖÉèÖÃ,
# mysql-data-d ......
Ò» . °²×°ÓëÅäÖÃMYSQL
¶þ . ³£ÓÃmysqlÃüÁîÐÐÃüÁî
1 .mysqlµÄÆô¶¯ÓëÍ£Ö¹
Æô¶¯MYSQL·þÎñ net start mysql
Í£Ö¹MYSQL·þÎñ net stop mysql
2 . netstat –na | findstr 3306 ²é¿´±»¼àÌýµÄ¶Ë¿Ú , findstrÓÃÓÚ²éÕÒºóÃæµÄ¶Ë¿ÚÊÇ·ñ´æÔÚ
3 . ÔÚÃüÁîÐÐÖеǽMYSQL¿ØÖÆ̨ , ¼´Ê¹Óà MYSQL COMMEND LINE TOOL
& ......