Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

mysql alter Óï¾äÓ÷¨,Ìí¼Ó¡¢Ð޸ġ¢É¾³ý×Ö¶Î

//Ö÷¼ü
alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);
//Ôö¼ÓÒ»¸öÐÂÁÐ
alter table t2 add d timestamp;
alter table infos add ex tinyint not null default '0';
//ɾ³ýÁÐ
alter table t2 drop column c;
//ÖØÃüÃûÁÐ
alter table t1 change a b integer;
//¸Ä±äÁеÄÀàÐÍ
alter table t1 change b b bigint not null;
alter table infos change list list tinyint not null default '0';
//ÖØÃüÃû±í
alter table t1 rename t2;
¼ÓË÷Òý
mysql> alter table tablename change depno depno int(5) not null;
mysql> alter table tablename add index Ë÷ÒýÃû (×Ö¶ÎÃû1[£¬×Ö¶ÎÃû2 …]);
mysql> alter table tablename add index emp_name (name);
¼ÓÖ÷¹Ø¼ü×ÖµÄË÷Òý
mysql> alter table tablename add primary key(id);
¼ÓΨһÏÞÖÆÌõ¼þµÄË÷Òý
mysql> alter table tablename add unique emp_name2(cardnumber);
ɾ³ýij¸öË÷Òý
mysql>alter table tablename drop index emp_name;
ÐÞ¸Ä±í£º
Ôö¼Ó×ֶΣº
mysql> ALTER TABLE table_name ADD field_name field_type;
ÐÞ¸ÄÔ­×Ö¶ÎÃû³Æ¼°ÀàÐÍ£º
mysql> ALTER TABLE table_name CHANGE old_field_name new_field_name field_type;
ɾ³ý×ֶΣº
mysql> ALTER TABLE table_name DROP field_name;


Ïà¹ØÎĵµ£º

11 advanced MySQL questions

 

Explain MySQL architecture
. - The front layer
takes care of network connections and security authentications, the
middle layer does the SQL query parsing, and then the query is handled
off to the storage engine. A storage engine could be either a default
one supp ......

MYSQLÊý¾Ý¿âʵÓÃѧϰ×ÊÁÏÖ®³£ÓÃÃüÁºÏ

 MysqlÊý¾Ý¿âÊÇÒ»¸ö¶àÓû§£¬¶àÏ̵߳ĹØϵÐÍÊý¾Ý¿â£¬ÊÇÒ»¸ö¿Í»§»ú/·þÎñÆ÷½á¹¹µÄÓ¦ÓóÌÐò¡£ËüÊǶԸöÈËÓû§ºÍÉÌÒµÓû§ÊÇÃâ·ÑµÄ.
MysqlÊý¾Ý¿â¾ßÓÐÒÔÏÂÓŵ㣺
1.ͬʱ·ÃÎÊÊý¾Ý¿âµÄÓû§µÄÊýÁ¿²»ÊÜÏÞÖÆ
2.¿ÉÒÔ±£´æ³¬¹ý5ǧÍòÌõµÄ¼Ç¼
3.ÊÇÄ¿Ç°Êг¡ÉÏÏÖÓÐÊý¾Ý¿â²úÆ·ÖÐÔËÐÐËÙ¶È×î¿ìµÄÊý¾Ý¿âϵͳ
4.Óû§È¨ÏÞÉèÖüòµ¥¡¢ÓÐ ......

MySQLÊý¾Ý¿âÖеÄShowÃüÁî¾ßÌåÓ÷¨

 MySQLÖÐÓкܶàµÄ»ù±¾ÃüÁshowÃüÁîÒ²ÊÇÆäÖÐÖ®Ò»£¬ÔںܶàʹÓÃÕßÖжÔshowÃüÁîµÄʹÓû¹ÈÝÒײúÉú»ìÏý£¬±¾ÎĻ㼯ÁËshowÃüÁîµÄÖÚ¶àÓ÷¨¡£
a. show tables»òshow tables from database_name; -- ÏÔʾµ±Ç°Êý¾Ý¿âÖÐËùÓбíµÄÃû³Æ¡£
b. show databases; -- ÏÔʾmysqlÖÐËùÓÐÊý¾Ý¿âµÄÃû³Æ¡£
c. show columns from table_nam ......

mysql±¸·ÝÊý¾Ý¿âÒÔ¼°¿½±´Êý¾Ý¿âµ½Áíһ̨·þÎñÆ÷ÉÏ

 ÏîÄ¿Òª½áÊøÁË...ÖÁÉÙ¿ª·¢Òª½áÊøÁË...
»ØÍ·¿´¿´×Ô¼º¾ÍÕâôһ¸öÈËÂñÍ·¿ª·¢ÁË4¸öÔ£¬ÒÔ¼°ÊÖÉÏÄõ½µÄÓë×Ô¼º¸¶³öÍêÈ«²»³ÉÕý±ÈµÄ΢±¡¹¤×Ê£¬¾õµÃ×Ô¼ºÕætmdµÄ±¯¾ç£¡
»òÐíÕâ¾ÍÊÇÓ¦½ì±ÏÒµÉúµÄÃü°É...¶÷£¬ÏÖÔÚÎÒÒѾ­²»ÊÇÓ¦½ì±ÏÒµÉúÁË...
ÏÖÔÚÏîÄ¿×öÍêÁË£¬ÎÒÒ²¾¡µ½ÁËÉÆʼÉÆÖÕµÄÒåÎñÁË...
¿àË®¾Íµ¹µ½ÕâÀ»¹ÊǻعéÕýÌâ¡£
ÓÉÓ ......

mysqlº¯Êý»ã×Ü


Ò»¡¢
¿ØÖÆÁ÷³Ìº¯Êý
a)        
CASE WHEN THEN
º¯Êý
Óï·¨£º
CASE value WHEN [compare-value]
THEN result [WHEN [compare-value] THEN result ……] [ELSE result ] END CASE WHEN
[condition] THEN result [WHEN[condition] THEN result …… ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ