mysqlÖÐɾ³ýÁеÄÏÂÁî
mysql ÖÐɾ³ýÁеÄÏÂÁîÊÇ alter table£¬Ó﷨Ϊ alter table table_name drop column column_name£¬¿ÉÓÃÓÚɾ³ý·ÇÖ÷¼üÁУ¬É¾³ýÇ°ÏßÖÐÊý¾Ý±ØÐèΪ¿Õ»ò¿ÉΪ null£¬É¾³ýºóÁÐÖÐÊý¾Ý½«É¥Ê§£¬¹ØÓÚ innodb ±í£¬É¾³ýÁкó±í½«ÖØÐÞ¡£
MySQL ÖÐɾ³ýÁеÄÏÂÁî
ALTER TABLE ÏÂÁîÓÃÓÚÔÚ MySQL ±íÖÐɾ³ýÁС£ÈçÏÂËùʾ£º
ALTER TABLE table_name DROP COLUMN column_name;
µÇ¼ºó¸´ÖÆ
Óï·¨£º
table_name£ºÒª´ÓÖÐɾ³ýÁеıíÃû¡£
column_name£ºÒªÉ¾³ýµÄÁÐÃû¡£
ʾÀý£º
Òª´ÓÃûΪ “customers” µÄ±íÖÐɾ³ý “email” ÁУ¬ÇëʹÓÃÒÔÏÂÏÂÁ
ALTER TABLE customers DROP COLUMN email;
µÇ¼ºó¸´ÖÆ
×¢ÖØ£º
Ö»ÄÜɾ³ý·ÇÖ÷¼üÁС£
ɾ³ýµÄÁбØÐèΪ¿Õ»ò°üÀ¨¿ÉΪ NULL µÄÖµ¡£
ɾ³ýÁк󣬸ÃÁÐÖеÄËùÓÐÊý¾Ý¶¼½«É¥Ê§¡£
¹ØÓÚ InnoDB ±í£¬É¾³ýÁÐºó£¬¸Ã±í½«±»ÖØÐÞ£¬Õâ¿ÉÄÜÐèÒªÒ»¶Îʱ¼ä¡£
ÒÔÉϾÍÊÇmysqlÖÐɾ³ýÁеÄÏÂÁîµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡
ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£