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

MySQLµÄÍâ¼üºÍ²ÎÕÕÍêÕûÐÔ

Ò»¡¢²ÎÕÕÍêÕûÐÔ(Referential integrity)ºÍÍâ¼ü(foreign key)
²ÎÕÕÍêÕûÐÔ(Referential integrity)ÊÇÓÃÓÚÔ¼¶¨Á½¸ö¹Øϵ֮¼äµÄÁªÏµ£¬ÀíÂÛÉϹ涨£ºÈôMÊǹØϵSÖеÄÒ»ÊôÐÔ×飬ÇÒMÊÇÁíÒ»¹ØϵZµÄÖ÷¹Ø¼ü×Ö£¬Ôò³ÆMΪ¹ØϵS¶ÔÓ¦¹ØϵZµÄÍâ¹Ø¼ü×Ö¡£ÈôMÊǹØϵSµÄÍâ¹Ø¼ü×Ö£¬ÔòSÖÐÿһ¸öÔª×éÔÚMÉϵÄÖµ±ØÐëÊÇ¿ÕÖµ»òÊǶÔÓ¦¹ØϵZÖÐij¸öÔª×éµÄÖ÷¹Ø¼ü×ÖÖµ¡£²ÎÕÕÍêÕûÐÔÊÇÊý¾Ý¿âÉè¼ÆÖÐÒ»¸öÖØÒªµÄ¸ÅÄî¡£ÔÚϵͳ²»Í¬µÄ±íÖУ¬µ±Êý¾Ý¿âËùÓвÎÕպϷ¨»ò·ÇºÏ·¨¹ØÁªÊ±¶¼»áÉæ¼°µ½²ÎÕÕÍêÕûÐÔ¡£µ±²ÎÕÕÍêÕûÐÔ´æÔÚʱ£¬ÈκÎÓë²»´æÔڵļǼ²úÉú¹ØÁª½«±äµÃÎÞЧ£¬ÓÉ´Ë¿É·ÀÖ¹Óû§³öÏÖ¸÷ÖÖ´íÎ󣬴ӶøÌṩ¸üΪ׼ȷºÍʵÓõÄÊý¾Ý¿â¡£
Íâ¼ü(foreign key):Èç¹û±íAµÄÖ÷¹Ø¼ü×ÖÊDZíBÖеÄ×ֶΣ¬Ôò¸Ã×ֶγÆΪ±íBµÄÍâ¼ü£¬±íA³ÆΪÖ÷±í£¬±íB³ÆΪ´Ó±í¡£Íâ¼üÊÇÓÃÀ´ÊµÏÖ²ÎÕÕÍêÕûÐԵģ¬²»Í¬µÄÍâ¼üÔ¼Êø·½Ê½½«¿ÉÒÔʹÁ½Õűí½ôÃܵĽáºÏÆðÀ´£¬ÌرðÊÇÐ޸ĻòÕßɾ³ýµÄ¼¶Áª²Ù×÷½«Ê¹µÃÈÕ³£µÄά»¤¹¤×÷¸ü¼ÓÇáËÉ¡£
¶þ¡¢MySQLÖеÄÍâ¼üʹÓÃÌõ¼þ
MySQLÒÔÍù²¢²»Ö§³ÖÍâ¼ü£¬Ô­ÒòÊÇÕâÖÖÖ§³Ö»á½µµÍËٶȺÍÐÔÄÜ¡£
ÔÚMySQL 3.23.44°æ±¾ºó£¬InnoDBÒýÇæÀàÐ͵ıíÖ§³ÖÁËÍâ¼üÔ¼Êø£¬µ«ÊÇĬÈÏÒýÇæMyISAMÄ¿Ç°»¹²»Ö§³ÖÍâ¼ü£¬Òò´ËʹÓÃʱÐèҪעÒ⽨Á¢Êý¾Ý¿â±íʱѡÔñInnoDB×÷ΪÊý¾Ý¿âÒýÇæ¡£
Íâ¼üµÄʹÓÃÌõ¼þ£º
1.Á½¸ö±í±ØÐëÊÇInnoDB±í£¬MyISAM±íÔÝʱ²»Ö§³ÖÍâ¼ü£¨¾Ý˵ÒÔºóµÄ°æ±¾ÓпÉÄÜÖ§³Ö£¬Ä¿Ç°ÎÒʹÓõÄÊÇ5.1.36»¹Ã»ÓÐÖ§³Ö£©£»
2.Íâ¼üÁбØÐ뽨Á¢ÁËË÷Òý£¬MySQL 4.1.2ÒÔºóµÄ°æ±¾ÔÚ½¨Á¢Íâ¼üʱ»á×Ô¶¯´´½¨Ë÷Òý£¬µ«Èç¹ûÔÚ½ÏÔçµÄ°æ±¾ÔòÐèÒªÏÔʾ½¨Á¢£»
3.Íâ¼ü¹ØϵµÄÁ½¸ö±íµÄÁбØÐëÊÇÊý¾ÝÀàÐÍÏàËÆ£¬Ò²¾ÍÊÇ¿ÉÒÔÏ໥ת»»ÀàÐ͵ÄÁУ¬±ÈÈçintºÍtinyint¿ÉÒÔ£¬¶øintºÍcharÔò²»¿ÉÒÔ£»
 
Èý¡¢Íâ¼üµÄÓï·¨
[CONSTRAINT symbol] FOREIGN KEY [id] (index_col_name, ...)
    REFERENCES tbl_name (index_col_name, ...)
    [ON DELETE {RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT}]
    [ON UPDATE {RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT}]
¸ÃÓï·¨¿ÉÒÔÔÚ CREATE TABLE ºÍ ALTER TABLE ʱʹÓã¬Èç¹û²»Ö¸¶¨CONSTRAINT symbol£¬MYSQL»á×Ô¶¯Éú³ÉÒ»¸öÃû×Ö¡£
ON DELETE¡¢ON UPDATE±íʾʼþ´¥·¢ÏÞÖÆ£¬¿ÉÉè²ÎÊý£º
RESTRICT£¨ÏÞÖÆÍâ±íÖеÄÍâ¼ü¸Ä¶¯£©
CASCADE£¨¸úËæÍâ¼ü¸Ä¶¯£©
SET NULL£¨Éè¿ÕÖµ£©
SET DEFAULT£¨ÉèĬÈÏÖµ£©
NO ACTION£¨ÎÞ¶¯×÷£¬Ä¬Èϵģ©
¾ßÌåʹÓÃʾÀý¿ÉÒÔ²


Ïà¹ØÎĵµ£º

ͨ¹ý·ÖÇø£¨Partition£©ÌáÉýMySQLÐÔÄÜ

 
ͨ¹ý·ÖÇø£¨Partition£©ÌáÉýMySQLÐÔÄÜ
×÷Õߣºfoxcai À´Ô´:foxcai µÄ Blog (2006-05-08 14:30:34)
ͨ¹ý·ÖÇø£¨Partition£©ÌáÉýMySQLÐÔÄÜ
               ——MySQL5.1ÐÂÌØÐÔ·­ÒëϵÁÐ
¼¸ÄêÇ°£¬°³Ð´¹ýһƪÌâΪ“The Founda ......

Ó°ÏìMysqlÐÔÄܵļ¸¸öÖØÒª²ÎÊý˵Ã÷

innodb_buffer_pool_size
Èç¹ûÓÃInnodb£¬ÄÇôÕâÊÇÒ»¸öÖØÒª±äÁ¿¡£Ïà¶ÔÓÚMyISAMÀ´Ëµ£¬Innodb¶ÔÓÚbuffer size¸üÃô¸Ð¡£MySIAM¿ÉÄܶÔÓÚ´óÊý¾ÝÁ¿Ê¹ÓÃĬÈϵÄkey_buffer_sizeÒ²»¹ºÃ£¬µ«InnodbÔÚ´óÊý¾ÝÁ¿Ê±ÓÃĬÈÏÖµ¾Í¸Ð¾õÔÚÅÀÁË¡£ InnodbµÄ»º³å³Ø»á»º´æÊý¾ÝºÍË÷Òý£¬ËùÒÔ²»ÐèÒª¸øϵͳµÄ»º´æÁô¿Õ¼ä£¬Èç¹ûÖ»ÓÃInnodb£¬¿ÉÒÔ°ÑÕâ¸öÖµÉèΪ ......

MySQL 5.4µÄÐÂÌØÐÔ½âÎö

Author: Ivan@mysqlab.net/Ì·¿¡Çà תÔØÇë×¢Ã÷À´Ô´URIÁ´½Ó:
http://www.mysqlab.net/blog/2009/04/mysql-54µÄÐÂÌØÐÔ½âÎö/
MySQL 5.4 Ö®ËùÒÔÃüÃûΪ5.4£¬¶ø²»ÊÇ5.2 ÊÇÒòΪ֮ǰµÄ5.2°æ±¾±»ÃüÃûΪ6.0ÁË£¨Õâ¸öÓ¦¸ÃÊÇÉÌÒµÉϵÄÔ­Òò£¬¾ÍÏñjava1.6±»ÃüÃûΪ6.0£©¡£ÏÖÔÚµÄ5.4 preview release ÊÇÔÚµ±Ç°MySQL5.1µÄ»ù´¡ÉÏ£¬¶Ô Innodb ½ø ......

Tomcat6 mysql jdbcÁ¬½Ó³ØµÄÅäÖÃ

 ÅªÁËÒ»ÍíÉÏ£¬²éÁËn¶àÎÄÕ£¬³¢ÊÔÁËn¶à¸´Ôӵķ½·¨£¬×îºóÖÕÓÚÔÚһƪÎÄÕÂÖÐÕÒµ½ÁËÒ»¸ö³¬¼òµ¥µÄ·½·¨£¬ÕæÊÇ̤ÆÆÌúЬÎÞÃÙ´¦°¡£¡²»Óð´Õչܷ¨µÄ×ö·¨£¬Ö»Òª°´ÕÕÏÂÎĵķ½·¨±£¹ÜÄã¿ÉÒԳɹ¦ÅäÖÃtomcatµÄÁ¬½Ó³Ø¡£
½«tomcat/conf/context.xmlÎļþÖÃΪÒÔÏÂÄÚÈÝ¡£
<Context reloadable="true">
    < ......

dz̸MySQLÂý²éѯÈÕÖ¾¼°microslow patch(msl patch)

mysql(°üÀ¨ËùÓÐ5.*ϵÁÐ,5.1.21֮ǰ)µÄÂý²éѯÈÕ־ĬÈÏÊÇÒÔÃëΪµ¥Î»µÄ,¿ÉÒÔͨ¹ýset [session|global] long_query_time=1Õâ¸ö×îµÍÒ²¾ÍÊÇ¿ÉÒÔÉèÖõ½1Ãë,¶ÔÓÚ0.5,0.005Ö®Àà¾ÍÎÞÄÜΪÁ¦ÁË,Õâʱºò¿ÉÒÔÓÐmicroslow patch(msl patch)²¹¶¡À´Íê³ÉÕâÒ»¹¤×÷,Õâ¸ö¹¦Äܵĺô¦×ÔÈ»²»ÑÔ¶øÓ÷. ÔÚmysql5.1.21¼°ÒÔºó°æ±¾¿ÉÒÔͨ¹ýset [session|gl ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ