MySQL Íâ¼üʹÓÃ
Íâ¼üµÄʹÓÃÌõ¼þ£º
1.Á½¸ö±í±ØÐëÊÇInnoDB±í£¬MyISAM±íÔÝʱ²»Ö§³ÖÍâ¼ü£¨¾Ý˵ÒÔºóµÄ°æ±¾ÓпÉÄÜÖ§³Ö£¬µ«ÖÁÉÙĿǰ²»Ö§³Ö£©£»
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±íʾʼþ´¥·¢ÏÞÖÆ£¬¿ÉÉè²ÎÊý£º
£¨1£© CASCADE: ´Ó¸¸±íɾ³ý»ò¸üÐÂÇÒ×Ô¶¯É¾³ý»ò¸üÐÂ×Ó±íÖÐÆ¥ÅäµÄÐС£ON DELETE CASCADEºÍON UPDATE CASCADE¶¼¿ÉÓá£ÔÚÁ½¸ö±íÖ®¼ä£¬Äã²»Ó¦¶¨ÒåÈô¸ÉÔÚ¸¸±í»ò×Ó±íÖеÄͬһÁвÉÈ¡¶¯×÷µÄON UPDATE CASCADE×Ӿ䡣
£¨2£©SET NULL: ´Ó¸¸±íɾ³ý»ò¸üÐÂÐУ¬²¢ÉèÖÃ×Ó±íÖеÄÍâ¼üÁÐΪNULL¡£Èç¹ûÍâ¼üÁÐûÓÐÖ¸¶¨NOT NULLÏÞ¶¨´Ê£¬Õâ¾ÍÊÇΨһºÏ·¨µÄ¡£ON DELETE SET NULLºÍON UPDATE SET NULL×Ӿ䱻֧³Ö¡£
£¨3£©NO ACTION: ÔÚANSI SQL-92±ê×¼ÖУ¬NO ACTIONÒâζÕâ²»²ÉÈ¡¶¯×÷£¬¾ÍÊÇÈç¹ûÓÐÒ»¸öÏà¹ØµÄÍâ¼üÖµÔÚ±»²Î¿¼µÄ±íÀɾ³ý»ò¸üÐÂÖ÷Òª¼üÖµµÄÆóͼ²»±»ÔÊÐí½øÐУ¨Gruber, ÕÆÎÕSQL, 2000:181£©¡£ InnoDB¾Ü¾ø¶Ô¸¸±íµÄɾ³ý»ò¸üвÙ×÷¡£
£¨4£©RESTRICT: ¾Ü¾ø¶Ô¸¸±íµÄɾ³ý»ò¸üвÙ×÷¡£NO ACTIONºÍRESTRICT¶¼Ò»Ñù£¬É¾³ýON DELETE»òON UPDATE×Ӿ䡣£¨Ò»Ð©Êý¾Ý¿âϵͳÓÐÑÓÆÚ¼ì²é£¬²¢ÇÒNO ACTIONÊÇÒ»¸öÑÓÆÚ¼ì²é¡£ÔÚMySQLÖУ¬Íâ¼üÔ¼ÊøÊDZ»Á¢¼´¼ì²éµÄ£¬ËùÒÔNO ACTIONºÍRESTRICTÊÇͬÑùµÄ£©¡£
£¨5£©SET DEFAULT: Õâ¸ö¶¯×÷±»½âÎö³ÌÐòʶ±ð£¬µ«InnoDB¾Ü¾ø°üº¬ON DELETE SET DEFAULT»òON UPDATE SET DEFAULT×Ó¾äµÄ±í¶¨Òå¡£
Ïà¹ØÎĵµ£º
×öÏîĿʱÓÉÓÚÒµÎñÂß¼µÄÐèÒª£¬±ØÐë¶ÔÊý¾Ý±íµÄÒ»Ðлò¶àÐмÓÈëÐÐËø£¬¾Ù¸ö×î¼òµ¥µÄÀý×Ó£¬Í¼Êé½èÔÄϵͳ¡£¼ÙÉè id=1 µÄÕâ±¾Êé¿â´æÎª 1 £¬µ«ÊÇÓÐ 2 ¸öÈËͬʱÀ´½èÕâ±¾Ê飬´Ë´¦µÄÂ߼Ϊ
view plaincopy to clipboardprint?
Select restnum from book where id =1 ; ......
×öÏîĿʱÓÉÓÚÒµÎñÂß¼µÄÐèÒª£¬±ØÐë¶ÔÊý¾Ý±íµÄÒ»Ðлò¶àÐмÓÈëÐÐËø£¬¾Ù¸ö×î¼òµ¥µÄÀý×Ó£¬Í¼Êé½èÔÄϵͳ¡£¼ÙÉè id=1 µÄÕâ±¾Êé¿â´æÎª 1 £¬µ«ÊÇÓÐ 2 ¸öÈËͬʱÀ´½èÕâ±¾Ê飬´Ë´¦µÄÂ߼Ϊ :
Select restnum from book where id =1 ;
-- Èç¹û restnum ´óÓÚ 0 £¬Ö´ÐÐ update
Update boo ......
The vs2008 and vs2010 don't support the generation LINQ to SQL business objects from a MySQL database, if you drop a MySql table to a Linq to Sql Class, it will popup a "The selected object(s) use an unsupported data provider" error.
Generation tool DBLinq
DbLinq is a LINQ to SQL data co ......
ASPÁ¬½ÓMySQLÊý¾Ý¿âµÄ·½·¨
ASPµÈÓïÑÔÁ¬½ÓmysqlÊý¾Ý¿â£¬¿ÉÒÔͨ¹ý°²×°mysqlµÄODBCÇý¶¯£¬Í¨¹ýÅäÖÃODBCÊý¾ÝÔ´£¬Á¬½Ó²¢²Ù×÷Êý¾Ý¿â¡£
mysql odbc 3.51°æ
ÏÂÔØµØÖ·:
http://dev.mysql.com/downloads/connector/odbc/3.51.html
£¼%
'²âÊÔ¶ÁÈ¡MySqlÊý¾Ý¿âµÄÄÚÈÝ
strconnection="driver={mysql odb ......
MySQLÓÐÒ»¸ö¹¦ÄܾÍÊÇ¿ÉÒÔlogÏÂÀ´ÔËÐеıȽÏÂýµÄsqlÓï¾ä£¬Ä¬ÈÏÊÇûÓÐÕâ¸ölogµÄ£¬ÎªÁË¿ªÆôÕâ¸ö¹¦ÄÜ£¬ÒªÐÞ¸Ämy.cnf»òÕßÔÚMySQLÆô¶¯µÄʱºò¼ÓÈëһЩ²ÎÊý¡£
Èç¹ûÔÚmy.cnfÀïÃæÐ޸ģ¬ÐèÔö¼ÓÈçϼ¸ÐÐ
long_query_time = 1
log-slow-queries =
log-queries-not-using-indexes
long_query_time ÊÇÖ¸Ö´Ðг¬¹ý¶à¾ÃµÄsql»á±»logÏÂÀ´£ ......