mysqlÖÐÔõÑùÉèÖÃnull
mysql ÖÐÉèÖà null µÄÒªÁì°üÀ¨£º1. ʹÓà insert Óï¾ä²åÈë null Öµ£»2. ʹÓà update Óï¾ä¸üÐÂֵΪ null£»3. ʹÓà alter table Óï¾ä½«ÁÐÉèÖÃΪÔÊÐí null£»4. ʹÓà default null Òªº¦×Ö½¨Éèбíʱ½«ÁеÄĬÈÏÖµÉèÖÃΪ null¡£ÐèҪעÖØ£¬null ²î±ðÓÚ¿Õ×Ö·û´®»òÁ㣬ÔÚ½ÏÁ¿Ê±Ê¼ÖÕΪ false£¬ÇÒÓ¦ÉóÉ÷ʹÓÃËüÒÔ×èÖ¹Êý¾ÝÍêÕûÐÔÎÊÌâ¡£
ÔõÑùÔÚ MySQL ÖÐÉèÖÃ NULL
NULL ÔÚ MySQL ÖÐÌåÏÖÒ»¸öδ֪»ò²»±£´æµÄÖµ¡£ÉèÖà NULL µÄÒªÁìÈçÏ£º
1. ʹÓà INSERT Óï¾ä
INSERT INTO table_name (column_name) VALUES (NULL);
µÇ¼ºó¸´ÖÆ
2. ʹÓà UPDATE Óï¾ä
UPDATE table_name SET column_name = NULL WHERE condition;
µÇ¼ºó¸´ÖÆ
3. ʹÓà ALTER TABLE Óï¾ä
Òª½«ÁÐÉèÖÃΪÔÊÐí NULL£¬¿ÉÒÔʹÓà ALTER TABLE Óï¾ä£¬ÈçÏÂËùʾ£º
ALTER TABLE table_name ALTER COLUMN column_name SET NULL;
µÇ¼ºó¸´ÖÆ
4. ʹÓà DEFAULT Òªº¦×Ö
½¨Éèбíʱ£¬¿ÉÒÔʹÓà DEFAULT NULL Òªº¦×Ö½«ÁеÄĬÈÏÖµÉèÖÃΪ NULL£¬ÈçÏÂËùʾ£º
CREATE TABLE table_name (column_name VARCHAR(255) DEFAULT NULL);
µÇ¼ºó¸´ÖÆ
×¢ÖØÊÂÏ
NULL ²¢²î±ðÓÚ¿Õ×Ö·û´®»òÁã¡£
NULL ÖµÔÚ½ÏÁ¿Ê±Ê¼ÖÕΪ false¡£
×èÖ¹ÔÚÉæ¼°ÊýѧÔËËãµÄÁÐÖÐʹÓà NULL£¬ÓÉÓÚËü¿ÉÄܻᵼÖÂÒâÍâЧ¹û¡£
Ã÷ÖǵØʹÓà NULL£¬ÓÉÓÚËü¿ÉÄÜ»áÒýÈëÊý¾ÝÍêÕûÐÔÎÊÌâ¡£
ÒÔÉϾÍÊÇmysqlÖÐÔõÑùÉèÖÃnullµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡