×ðÁú¿­Ê±¹ÙÍøµÇ¼

mysqlÖÐÖ÷¼ü¿ÉÒÔΪ¿ÕÂð

mysqlÖеÄÖ÷¼ü²»¿ÉΪ¿Õ£¬ÓÉÓÚÕâ»áÎ¥·´Î¨Ò»ÐÔÔ¼Êø£¬Ó°ÏìÊý¾ÝÍêÕûÐÔ£¬²¢½µµÍÅÌÎÊÐÔÄÜ¡£Î¨Ò»ÔÊÐíÖ÷¼üÖаüÀ¨nullÖµµÄÇéÐÎÊÇ×Ô¶¯µÝÔöÁкÍ×éºÏÖ÷¼üÖÐijЩÁÐΪ¿Õ¡£

MySQL ÖÐÖ÷¼ü¿ÉÒÔΪ¿ÕÂ𠣿

»Ø¸²£º·ñ£¬MySQL ÖеÄÖ÷¼ü²»¿ÉΪ¿Õ¡£

ÏêϸڹÊÍ£º

ÔÚ MySQL ÖУ¬Ö÷¼üÊÇÓÃÀ´Î¨Ò»±êʶ±íÖÐÿÌõ¼Í¼µÄÌØÊâÁС£Ö÷¼üÖµ±ØÐèÊǷǿյģ¬ÕâÒâζ×ÅËü²»¿É°üÀ¨ NULL Öµ¡£ÕâÊÇÓÉÓÚ£º

È·±£Êý¾ÝÍêÕûÐÔ£ºÈôÊÇÖ÷¼üÔÊÐíΪ¿Õ£¬Ôò¿ÉÄܻᵼÖ±íÖзºÆðÖظ´¼Í¼¡£ÕâÊÇÓÉÓÚÁ½¸ö²î±ðµÄ¼Í¼¿ÉÒÔ¾ßÓÐÏàͬµÄÖ÷¼ü£¬´Ó¶øÎ¥·´ÁËÖ÷¼üµÄΨһÐÔÔ¼Êø¡£

ÓÅ»¯ÅÌÎÊÐÔÄÜ£ºMySQL ʹÓÃÖ÷¼üÀ´¿ìËÙ¼ìË÷Êý¾Ý¡£ÈôÊÇÖ÷¼ü¿ÉÒÔΪ¿Õ£¬ÔòÊý¾Ý¿â½«ÎÞ·¨ÓÐÓõØʹÓÃË÷ÒýÀ´ÓÅ»¯ÅÌÎÊ£¬Õ⽫µ¼ÖÂÅÌÎÊÐÔÄÜϽµ¡£

˵Ã÷£º

ÔÚ MySQL ÖУ¬Äú¿ÉÒÔͨ¹ýÉèÖà NOT NULL Ô¼ÊøÀ´Ç¿ÖÆÖ÷¼üÁÐΪ·Ç¿Õ¡£ÀýÈ磺

CREATE TABLE my_table (
    id INT NOT NULL PRIMARY KEY,
    name VARCHAR(255)
);

µÇ¼ºó¸´ÖÆ

ÆÆÀýÇéÐΣº

ÔÚijЩÇéÐÎÏ£¬MySQL ÔÊÐíÔÚijЩÁÐÖÐʹÓà NULL Öµ×÷ΪÖ÷¼ü¡£ÕâЩÆÆÀý°üÀ¨£º

×Ô¶¯µÝÔöÁУºMySQL ¿ÉÒÔ½« AUTO_INCREMENT ÁÐÓÃ×÷Ö÷¼ü£¬×ÝÈ»Ëü°üÀ¨ NULL Öµ¡£ÕâÊÇÓÉÓÚ MySQL ÔÚ²åÈëмͼʱ»á×Ô¶¯·ÖÅÉΨһֵ¡£

×éºÏÖ÷¼ü£ºMySQL ÔÊÐíÔÚ×éºÏÖ÷¼üÖÐʹÓà NULL Öµ£¬Ö»ÒªÖ÷¼üÖеÄÆäËûÁаüÀ¨·Ç¿ÕÖµ¡£ÀýÈ磬ÈôÊÇ (id1, id2) ÊÇÒ»¸ö×éºÏÖ÷¼ü£¬Ôò id1 ¿ÉÒÔΪ¿Õ£¬Ö»Òª id2 ¾ßÓзǿÕÖµ¡£

È»¶ø£¬ÕâЩÆÆÀýÇéÐβ»ÊÊÓÃÓÚͨË×µÄÖ÷¼üÁС£ÔÚ´ó´ó¶¼ÇéÐÎÏ£¬MySQL ÖеÄÖ÷¼ü±ØÐèÊǷǿյġ£

ÒÔÉϾÍÊÇmysqlÖÐÖ÷¼ü¿ÉÒÔΪ¿ÕÂðµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ