sqlÖÐcolumnʲôÒâ˼
sql Êý¾Ý¿âÖУ¬ÁÐÊDZÊÖ±´æ´¢Êý¾ÝµÄ×ֶΣ¬¾ßÓÐΨһÃû³ÆºÍÖ¸¶¨µÄÊý¾ÝÀàÐÍ¡£ÁаüÀ¨£ºÁÐÃû¡¢Êý¾ÝÀàÐÍ¡¢Ô¼Êø¡¢Ä¬ÈÏÖµ¡£ÁÐÓÃÓÚ×éÖ¯Êý¾Ý£¬²¢Í¨¹ýÔ¼ÊøÈ·±£Êý¾ÝµÄÍêÕûÐÔ¡£¿ÉÒÔͨ¹ý create table Óï¾ä½¨ÉèÁУ¬²¢Í¨¹ý alter table Óï¾ä¶ÔÆä¾ÙÐвÙ×÷£¬°üÀ¨Ìí¼Ó¡¢É¾³ý¡¢Ð޸ĺÍÅÌÎÊÊý¾Ý¡£
SQL ÖеÄÁÐ
ÔÚ SQL Êý¾Ý¿âÖУ¬ÁÐÊDZíÖеıÊÖ±×ֶΣ¬Ëü´æ´¢Ìض¨ÀàÐÍÊý¾ÝµÄÜöÝÍ¡£Ã¿Áж¼ÓÐÒ»¸öΨһÃû³Æ£¬²¢Ö¸¶¨ÁË¿ÉÒÔ´æ´¢ÔÚ´ËÁÐÖеÄÊý¾ÝÀàÐÍ¡£
ÁеÄ×é³É²¿·Ö
ÁÐÃû£ºÓÃÓÚ±êʶÁеÄΨһÃû³Æ¡£
Êý¾ÝÀàÐÍ£ºÖ¸¶¨ÁÐÖпÉÒÔ´æ´¢µÄÊý¾ÝÀàÐÍ£¬ÀýÈçÎı¾¡¢Êý×Ö¡¢ÈÕÆÚ»ò²¼¶ûÖµ¡£
Ô¼Êø£º¶ÔÁÐÖпÉÒÔ´æ´¢µÄÊý¾ÝÓ¦ÓÃÏÞÖÆ£¬ÀýÈçΨһÐÔ¡¢·Ç¿ÕÐԺ͹æÄ£¡£
ĬÈÏÖµ£ºµ±ÐÂÐвåÈë±íÖÐʱ£¬ÈôÊÇδָ¶¨Öµ£¬Ôò·ÖÅɸøÁеÄĬÈÏÖµ¡£
ÁеÄÖ÷ÒªÐÔ
ÁйØÓÚ×éÖ¯±íÖеÄÊý¾ÝÖÁ¹ØÖ÷Òª¡£ËüÃÇÔÊÐíÓû§°´Ìض¨×ֶζÔÊý¾Ý¾ÙÐÐÅÅÐò¡¢·Ö×éºÍ¹ýÂË¡£±ðµÄ£¬ÁÐÔ¼ÊøÈ·±£Êý¾ÝµÄÍêÕûÐÔ£¬±ÜÃâÎÞЧ»ò·×ÆçÖµÄÊý¾Ý½øÈë±íÖС£
ÔõÑù½¨ÉèÁÐ
ÔÚ½¨Éèбíʱ£¬¿ÉÒÔͨ¹ýʹÓà CREATE TABLE Óï¾äÏÔʽ½¨ÉèÁС£ÀýÈ磺
CREATE TABLE employees ( id INT NOT NULL PRIMARY KEY, name VARCHAR(255) NOT NULL, email VARCHAR(255) UNIQUE );
µÇ¼ºó¸´ÖÆ
ÔÚ±¾ÀýÖУ¬±í employees ÓÐÈý¸öÁУº
id ÊÇΨһ±êʶ·ûÁУ¬´æ´¢ÕûÊýÊý¾Ý¡£
name ÊÇÒ»¸öÎı¾ÁУ¬×î¶à¿É´æ´¢ 255 ¸ö×Ö·û¡£
email ÊÇÒ»¸öΨһµÄÎı¾ÁУ¬×î¶à¿É´æ´¢ 255 ¸ö×Ö·û¡£
ÔõÑù²Ù×÷ÁÐ
¿ÉÒÔ¶ÔÁÐÖ´ÐÐÖݪֲÙ×÷£¬ÀýÈ磺
Ìí¼ÓÁУºÊ¹Óà ALTER TABLE Óï¾äÏòÏÖÓбíÌí¼ÓÐÂÁС£
ɾ³ýÁУºÊ¹Óà ALTER TABLE Óï¾ä´ÓÏÖÓбíÖÐɾ³ýÁС£
ÐÞ¸ÄÁУºÊ¹Óà ALTER TABLE Óï¾ä¸ü¸ÄÁеÄÃû³Æ¡¢Êý¾ÝÀàÐÍ»òÔ¼Êø¡£
ÅÌÎÊÊý¾Ý£ºÊ¹Óà SELECT Óï¾ä´ÓÁÐÖмìË÷Êý¾Ý¡£
¸üÐÂÊý¾Ý£ºÊ¹Óà UPDATE Óï¾ä¸üÐÂÁÐÖеÄÊý¾Ý¡£
ÒÔÉϾÍÊÇsqlÖÐcolumnʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡