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

Web¿ª·¢±Ê¼Ç2——MySQLÊ°Áã

Ô­ÎÄ£ºhttp://blog.csdn.net/gnuhpc/archive/2010/01/01/5118123.aspx
½ö½öÊÇ¿´Ò»Ð©ÊéÊÇÁãÁãɢɢ¼Çϵģ¬¸ø×Ô¼º±¸Íü¶øÒÑ¡£½¨ÒéÈ¥¿´×¨ÒµÍøÕ¾µÄ±Ê¼Ç¡£
1.Ö÷¼üµÄÖµ±ØÐëÊÇΨһµÄ£¬²¢ÇÒ²»ÄÜΪ¿Õ£¬Õâ¿ÉÒÔÌá¸ßMySQL´Ó¶à¸ö±íÖÐÈ¡µÃÊý¾Ý»òÕßÈ¡µÃÖ¸¶¨¼üÖµ¶ÔÓ¦µÄÐеÄËٶȡ£MySQLͨ¹ýÒ»¸öÌØÊâµÄ³ÆΪIndexË÷ÒýµÄÊý¾Ý½á¹¹×öµ½ÕâÒ»µã£¬IndexÊÇÕÒµ½Ò»Ìõ¼Ç¼µÄ¿ì½Ý·½Ê½£¬¾ÍÏñͼÊé¹ÝµÄ¿¨Æ¬Ä¿Â¼¡£
2.²é¿´±íµÄÁж¨ÒåʹÓÃdescribeÃüÁî.
3.ÕûÊýÁдóСĬÈÏÊÇ11.
4.InsertʱÒýºÅµÄʹÓãºÊý×ÖÊýÖµ¡¢º¯ÊýºÍNULL²»ÒªÓã¬×Ö·û´®ÊýÖµ¡¢Ê±¼ä¡¢ÈÕÆÚÔòÒªÓÃÒýºÅÀ¨ÆðÀ´¡£
5.ʹÓÃalterÐÞ¸Ä±í¶¨Òåʱ£¬¼´Ê¹Ã»ÓиıäÁеÄÊý¾ÝÀàÐÍ£¬ÁеĶ¨ÒåÈÔÈ»±Ø²»¿ÉÉÙ¡£
6.ÔÚʹÓÃselectÓï¾äʱ£¬ÄãÓ¦¸ÃÑø³ÉTABLE.COLUMN·½Ê½À´ÒýÓÃÁУ¬ÕâÑù¿ÉÒÔ±ÜÃâ»ìÏý¡£
7.½á¹ûÅÅÐòÓÃselect XX from YY order by zz;
8.ʹÓÃ×ÔÈ»Á¬½Ónatural join¿ÉÒÔ±ÜÃâÊäÈëºÜ³¤µÄÃüÁMySQL¿ÉÒÔ°ÑÁ½¸ö±íÖеÄͬÃûÓòÁ¬½ÓÆðÀ´¡£¿ÉÒÔʹÓÃ×óÁ¬½Ó·½Ê½½«±íÁ¬½ÓÆðÀ´¡£
9.join onÒ²ÊÇÁ¬½Ó£¬µ«ÊÇÐèÒªÖ¸¶¨Òª½øÐÐÁ¬½ÓµÄÁС£SELECT * from books JOIN authors ON (books.title_id = authors.title_id);
10.ʹÓñðÃû¿ÉÒÔ½«³¤µÄ±íÃû»»³É½Ï¶ÌµÄ£¬»¹¿ÉÒÔÈÃÄãÔÚͬһ¸ö²éѯÖÐÁ½´ÎÒýÓÃͬһ¸ö±í¶øÇø·ÖÄ㾿¾¹ÊÇÒýÓõĵÚÒ»¸ö»¹Êǵڶþ¸ö¡£
SELECT * from books AS b,authors AS a WHERE b.title_id = a.title_id;
11.SQLÓï¾äÌص㣺×öʲô+ ´ó¸Å´ÓÄÄ+¾ßÌå´ÓÄÄ£¬ÀýÈçselect from * where title_id=1;
12.²éÕÒ£ºSELECT * from authors WHERE author LIKE "%b%"; °Ù·ÖºÅÊÇͨÅä·û£¬±íʾһ¸ö»ò¶à¸ö¡£¶øÏ»®Ïß_Ôò±íʾһ¸ö×Ö·û¡£
12.ͨ¹ý°üº¬ÁíÍâÒ»ÕűíµÄÖ÷¼ü¶øÐγɵıíÖ®¼äµÄÁ¬½Ó±»³ÆΪÍâ¼ü¹Øϵ¡£
13.Êý¾Ý¿âµÄ¹ØϵÓÐÈýÖÖ£ºÒ»¶ÔÒ»¡¢Ò»¶Ô¶à¡¢¶à¶Ô¶à¡£ÒÔÒ»¸öÔÚÏßÊéµêΪÀý£¬Óû§ºÍÆäÓʼĵØÖ·£¨¼ÙÉèÖ»ÄÜÉ趨һ¸öµØÖ·£©Ê±Ò»¶ÔÒ»µÄ¹Øϵ£¬¶øͼÊéµÄÀàÐÍÓë¾ßÌåÊé¼®ÔòÊÇÒ»¶Ô¶àµÄ¹Øϵ£¬Óû§¶ÔÊéÔòÊǶà¶Ô¶àµÄ¹Øϵ¡£¶à¶Ô¶àµÄ¹Øϵ±»×ª»»ÎªÁ½¸öÒ»¶Ô¶à¹ØϵµÄ±ä»»±í²ÅÄÜÔÚÊý¾Ý¿âÖÐÌåÏÖ³öÀ´¡£
14.¹æ·¶»¯£º
ÀíÇåÊý¾ÝÖ®¼äµÄ¹Øϵ²¢ÕÒ³ö×éÖ¯Êý¾ÝµÄ×îÓÐЧ·½Ê½µÄ¹ý³Ì±»³Æ×÷¹æ·¶»¯¡£Òª¹æ·¶»¯Ò»¸öÊý¾Ý¿â£¬ÐèÒª´Ó×î»ù´¡µÄ¹æÔò¿ªÊ¼£¬·ÖΪÈý¸ö½×¶Î——µÚÒ»·¶Ê½¡¢µÚ¶þ·¶Ê½¡¢µÚÈý·¶Ê½£¬ºóÕß±ØÐëÔÚÇ°ÕßÍê³ÉµÄ»ù´¡ÉϲſɵÃÒÔ½øÐС£
µÚÒ»·¶Ê½£º½â¾öÊý¾ÝÔÚͬһÐÐÄÚµÄÈßÓ࣬ҪÇóËùÓÐµÄ±í²»ÄÜÖظ´µÄ°üº¬Í¬ÑùµÄÊý¾ÝÁУ¬ËùÓеÄÁÐÖÐÖ»ÄÜ°üº¬Ò»¸öÖµ£¬±ØÐë´æÔÚÒ»¸öÖ÷¼ü¿ÉÒÔΨһָ¶¨Ò»ÐÐÊ


Ïà¹ØÎĵµ£º

MysqlÊýѧº¯Êý½âÎö

ËùÓеÄÊýѧº¯ÊýÔÚÒ»¸ö³ö´íµÄÇé¿öÏ·µ»ØNULL¡£ 

µ¥Ä¿¼õ¡£¸Ä±ä²ÎÊýµÄ·ûºÅ¡£ 
mysql> select - 2; 
×¢Ò⣬Èç¹ûÕâ¸ö²Ù×÷·ûÓëÒ»¸öBIGINTʹÓ㬷µ»ØÖµÊÇÒ»¸öBIGINT£¡ÕâÒâζ×ÅÄãÓ¦¸Ã±ÜÃâÔÚÕûÊýÉÏʹÓÃ-£¬ÄÇ¿ÉÄÜÓÐÖµ-2^63£¡ 
ABS(X)
·µ»ØXµÄ¾ø¶ÔÖµ¡£ 
mysql> select ABS(2);&n ......

mysql ³£ÓþÙÀý

drop table student;
create table student
(sno   int   not null unique,
 sname varchar(8) not null,
 ssex  char(2)    not null,
 sage int ,
 sdept varchar(20));
 
 select * from student;
 alter table student drop uniq ......

MySQL Ô¶³ÌÁ¬½Ó

ÎÊÌ⣺Զ³ÌÁ¬½Ó·þÎñÆ÷µÄÊý¾Ý¿â
$ mysql -hserverip -uuser -ppassword
ERROR 1045 (28000): Access denied for user 'user'@'localhost'
(using password: YES)
Ô­Òò£ºmysql.user±íÖÐûÓÐÉèÖÃÔ¶³ÌÁ¬½Ó
$ mysql -uroot -ppassword  #ÓÃrootÓû§ÔÚserverÉϵǼ
mysql> select host, user, password from mysql ......

MySQLÖÐÐÞ¸ÄÃÜÂë¼°·ÃÎÊÏÞÖÆÉèÖÃÏê½â

MySQLÊÇÒ»¸öÕæÕýµÄ¶àÓû§¡¢¶àÏß³ÌSQLÊý¾Ý¿â·þÎñÆ÷¡£MySQLÊÇÒÔÒ»¸ö¿Í»§»ú/·þÎñÆ÷½á¹¹µÄʵÏÖ£¬ËüÓÉÒ»
¸ö·þÎñÆ÷ÊØ»¤³ÌÐòmysqldºÍºÜ¶à²»Í¬µÄ¿Í»§³ÌÐòºÍ¿â×é³É¡£ÓÉÓÚÆäÔ´ÂëµÄ¿ª·ÅÐÔ¼°Îȶ¨ÐÔ£¬ÇÒÓëÍøÕ¾Á÷Ðбà徎ÓïÑÔPHPµÄÍêÃÀ½áºÏ£¬ÏÖÔںܶàÕ¾µã¶¼ÀûÓÃÆä
µ±×÷ºó¶ËÊý¾Ý¿â£¬Ê¹Æä»ñµÃÁ˹㷺ӦÓᣴ¦ÓÚ°²È«·½ÃæµÄ¿¼ÂÇ£¬ÐèҪΪà ......

ÈçºÎÐÞ¸ÄMYSQLµÄĬÈϱàÂë

MySQLµÄĬÈϱàÂëÊÇLatin1£¬²»Ö§³ÖÖÐÎÄ.ÒªÈÃĬÈϱàÂë±äΪutf8¡£¿É½øÐÐÈçÏÂÅäÖãº
SET GLOBAL character_set_client     = utf8;
SET GLOBAL character_set_connection = utf8;
SET GLOBAL character_set_database   = utf8;
SET GLOBAL character_set_results    = utf8; ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ