sqlÖÐɾ³ýÁеÄÏÂÁî
sql ÖÐɾ³ýÁеÄÏÂÁîΪ alter table drop column£¬ÓÃÓÚÐ޸ıí½á¹¹£¬É¾³ýÖ¸¶¨ÁС£°ì·¨°üÀ¨£º1. Ö¸¶¨ÒªÐ޸ĵıíÃû£»2. ʹÓà drop column ×Ó¾äÖ¸¶¨ÒªÉ¾³ýµÄÁÐÃû¡£
SQL ÖÐɾ³ýÁеÄÏÂÁî
SQL ÖÐɾ³ýÁеÄÏÂÁîÊÇ ALTER TABLE£¬ËüÔÊÐíÐ޸ıí½á¹¹£¬°üÀ¨É¾³ýÁС£
Óï·¨£º
ALTER TABLE table_name DROP COLUMN column_name;
µÇ¼ºó¸´ÖÆ
°ì·¨£º
Ö¸¶¨ÒªÐ޸ĵıíÃû table_name¡£
ʹÓà DROP COLUMN ×Ó¾äÖ¸¶¨ÒªÉ¾³ýµÄÁÐÃû column_name¡£
ʾÀý£º
¼ÙÉèÓÐÒ»¸öÃûΪ employee µÄ±í£¬Ëü°üÀ¨ÒÔÏÂÁУº
ÁÐÃû | Êý¾ÝÀàÐÍ |
---|---|
id | int |
name | varchar(255) |
age | int |
address | text |
Ҫɾ³ý address ÁУ¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ
ALTER TABLE employee DROP COLUMN address;
µÇ¼ºó¸´ÖÆ
×¢ÖØ£º
Ö»ÄÜɾ³ý±íÖв»±£´æÍâ¼üÔ¼ÊøµÄÁС£
ɾ³ýÁн«ÓÀÊÀɾ³ý¸ÃÁÐÖд洢µÄËùÓÐÊý¾Ý¡£
È·±£ÔÚɾ³ýÁÐ֮ǰ±¸·Ý±í£¬ÒÔ·ÀÍòÒ»±¬·¢Êý¾ÝɥʧµÄÇéÐΡ£
ÒÔÉϾÍÊÇsqlÖÐɾ³ýÁеÄÏÂÁîµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡
ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£