sqlÖÐÐ޸ıí½á¹¹µÄÏÂÁîÊÇ
sql ÖÐÐ޸ıí½á¹¹µÄÏÂÁîÊÇ alter table£¬Ö§³ÖÒÔϲÙ×÷£ºÊ¹Óà add column Ìí¼ÓÐÂÁÐʹÓà drop column ɾ³ýÏÖÓÐÁÐʹÓà alter column ÐÞ¸ÄÏÖÓÐÁÐÊôÐÔʹÓà add foreign key Ìí¼ÓÍâ¼üÔ¼ÊøʹÓà drop foreign key ɾ³ýÍâ¼üÔ¼ÊøʹÓà rename table Ð޸ıíÃû
SQL ÖÐÐ޸ıí½á¹¹µÄÏÂÁî
ÔÚ SQL ÖУ¬¿ÉÒÔʹÓà ALTER TABLE Óï¾äÀ´Ð޸ıí½á¹¹¡£ALTER TABLE Óï¾äÖ§³Ö¶Ô±í¾ÙÐÐÖÖÖÖÐ޸IJÙ×÷£¬°üÀ¨£º
Ìí¼ÓÁÐ
ʹÓà ADD COLUMN ×Ó¾äÌí¼ÓÐÂÁУº
ALTER TABLE table_name ADD COLUMN new_column_name data_type;
µÇ¼ºó¸´ÖÆ
ɾ³ýÁÐ
ʹÓà DROP COLUMN ×Ó¾äɾ³ýÏÖÓÐÁУº
ALTER TABLE table_name DROP COLUMN column_name;
µÇ¼ºó¸´ÖÆ
ÐÞ¸ÄÁÐ
ʹÓà ALTER COLUMN ×Ó¾äÐÞ¸ÄÏÖÓÐÁеÄÃû³Æ¡¢Êý¾ÝÀàÐÍ»òÆäËûÊôÐÔ£º
ALTER TABLE table_name ALTER COLUMN column_name new_column_name data_type;
µÇ¼ºó¸´ÖÆ
Ìí¼ÓÍâ¼ü
ʹÓà ADD FOREIGN KEY ×Ó¾äÌí¼ÓÍâ¼üÔ¼Êø£º
ALTER TABLE table_name ADD FOREIGN KEY (foreign_key_column) REFERENCES referenced_table(referenced_column);
µÇ¼ºó¸´ÖÆ
ɾ³ýÍâ¼ü
ʹÓà DROP FOREIGN KEY ×Ó¾äɾ³ýÏÖÓÐÍâ¼üÔ¼Êø£º
ALTER TABLE table_name DROP FOREIGN KEY foreign_key_name;
µÇ¼ºó¸´ÖÆ
Ð޸ıíÃû
ʹÓà RENAME TABLE ×Ó¾äÐ޸ıíÃû£º
RENAME TABLE old_table_name TO new_table_name;
µÇ¼ºó¸´ÖÆ
ÒÔÉϾÍÊÇsqlÖÐÐ޸ıí½á¹¹µÄÏÂÁîÊǵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡