MySql ±íµÄÖ÷¼üË÷ÒýÎÊÌâ
²é¿´Ä³¸ö±íµÄ½¨±íÓï¾ä £ºshow create table data_statdata;
drop index ts on data_statdata;
Ë÷ÒýÊǼÓËÙ²éѯµÄÖ÷ÒªÊֶΣ¬Ìرð¶ÔÓÚÉæ¼°¶à¸ö±íµÄ²éѯ¸üÊÇÈç´Ë¡£±¾½ÚÖУ¬½«½éÉÜË÷ÒýµÄ×÷Óá¢Ìص㣬ÒÔ¼°´´½¨ºÍɾ³ýË÷ÒýµÄÓï·¨¡£
13.4.1 ʹÓÃË÷ÒýÓÅ»¯²éѯ
Ë÷ÒýÊÇ¿ìËÙ¶¨Î»Êý¾ÝµÄ¼¼Êõ£¬Ê×ÏÈͨ¹ýÒ»¸öʾÀýÀ´Á˽âÆ京Òå¼°×÷Óã¬ÏêϸµÄ½éÉÜÇë²Î¿¼µÚ14Õ¡£
1£®Ë÷ÒýʾÀý
¼ÙÉè¶ÔÓÚ10.3½ÚËù½¨µÄ±í£¬¸÷¸ö±íÉ϶¼Ã»ÓÐË÷Òý£¬Êý¾ÝµÄÅÅÁÐҲûÓйæÂÉ£¬Èç±í13.3Ëùʾ¡£
±í13.3 ûÓÐË÷ÒýµÄstudents±í
sid
sname
sgender
sage
52
zhang
M
21
22
wang
M
22
33
li
F
19
41
zhao
M
20
...
...
...
µ±²éÕÒij¸öѧÉúÐÅϢʱ£¬±ØÐë˳Ðò²é¿´±ístudentsÖеÄÿһÐУ¬¼ì²éÊÇ·ñÓëËùÐèֵƥÅ䣬ÕâÐèҪɨÃèÈ«±í£¬Ð§Âʺܵ͡£
±í13.4¸ø³öÁËÔÚnameÁÐÉÏÔö¼ÓÁËË÷ÒýµÄstudents±í¡£
±í13.4 ÔÚnameÁÐÉÏÔö¼ÓÁËË÷ÒýµÄstudents±í
Ë÷ÒýÊÇÔÚnameÉÏÅÅÐòµÄ¡£ÏÖÔÚ£¬µ±²éÕÒij¸öѧÉúÐÅϢʱ£¬¾Í²»ÐèÒªÖðÐÐËÑË÷È«±í£¬¿ÉÒÔÀûÓÃË÷Òý½øÐÐÓÐÐò²éÕÒ£¨Èç¶þ·Ö²éÕÒ·¨£©£¬²¢¿ìËÙ¶¨Î»µ½Æ¥ÅäµÄÖµ£¬ÒÔ½ÚÊ¡´óÁ¿ËÑË÷ʱ¼ä¡£
2£®Ë÷Òý×÷ÓÃ
ÔÚË÷ÒýÁÐÉÏ£¬³ýÁËÉÏÃæÌáµ½µÄÓÐÐò²éÕÒÖ®Í⣬Êý¾Ý¿âÀûÓø÷ÖÖ¸÷ÑùµÄ¿ìËÙ¶¨Î»¼¼Êõ£¬Äܹ»´ó´óÌá¸ß²éѯЧÂÊ¡£ÌرðÊǵ±Êý¾ÝÁ¿·Ç³£´ó£¬²éѯÉæ¼°¶à¸ö±íʱ£¬Ê¹ÓÃË÷ÒýÍùÍùÄÜʹ²éѯËٶȼӿì³ÉǧÉÏÍò±¶¡£
ÀýÈ磬ÓÐ3¸öδË÷ÒýµÄ±ít1¡¢t2¡¢t3£¬·Ö±ðÖ»°üº¬ÁÐc1¡¢c2¡¢c3£¬Ã¿¸ö±í·Ö±ðº¬ÓÐ1000ÐÐÊý¾Ý×é³É£¬Ö¸Îª1¡«1000µÄÊýÖµ£¬²éÕÒ¶ÔÓ¦ÖµÏàµÈÐеIJéѯÈçÏÂËùʾ¡£
SELECT c1,c2,c3 from t1,t2,t3 WHERE c1=c2 AND c1=c3
´Ë²éѯ½á¹ûÓ¦¸ÃΪ1000ÐУ¬Ã¿Ðаüº¬3¸öÏàµÈµÄÖµ¡£ÔÚÎÞË÷ÒýµÄÇé¿öÏ´¦Àí´Ë²éѯ£¬±ØÐëÑ°ÕÒ3¸ö±íËùÓеÄ×éºÏ£¬ÒÔ±ãµÃ³öÓëWHERE×Ó¾äÏàÅäµ
Ïà¹ØÎĵµ£º
תµ½¸½Â¼1£¨mysql ÃüÁî´óÈ« - ÃüÁîÏê½â
£©
תµ½¸½Â¼2£¨mysqlÂÒÂëÎÊÌâ½â¾ö·½·¨
£©
ÔÚÎÒµÄFedoraÖУ¬ÔÚϵͳ°²×°Ê±ÎÒ¾ÍÑ¡Ôñ°²×°ÁËMysqlÁË£¬ËùÒԾͲ»ÓÃÔÙÈ¥ÏÂÔØÔ´´úÂ룬ȻºóÈ¥ÂýÂý±àÒë¡£¹þ¹þ£¬ÍµÁËÒ»¸öÀÁ¡£
ϵͳ°²×°ºÃÁË£¬Mysqlʱ±Ø²»¿ÉÉٵģ¬ËùÒÔÒ»¶¨Òª¼ìÑéÒ»ÏÂMysql¿ÉÒÔÓò»¡£
Ê×ÏÈÇл»µ½rootÕË»§£¬È»ºóÊäÈëÃüÁs ......
MySQLÃÜÂëÐ޸ķ½·¨
Ê×ÏÈÒªÉùÃ÷Ò»µã£¬´ó²¿·ÖÇé¿öÏ£¬ÐÞ¸ÄMySQLÊÇÐèÒªÓÐmysqlÀïµÄrootȨÏ޵ģ¬ËùÒÔÒ»°ãÓû§ÎÞ·¨¸ü¸ÄÃÜÂ룬³ý·ÇÇëÇó¹ÜÀíÔ±¡£
·½·¨Ò»
¡¡¡¡Ê¹ÓÃphpmyadmin£¬ÕâÊÇ×î¼òµ¥µÄÁË£¬ÐÞ¸Ämysql¿âµÄuser±í£¬
¡¡¡¡²»¹ý±ðÍüÁËʹÓÃPASSWORDº¯Êý¡£
¡¡¡¡·½·¨¶þ
¡¡ ......
mysqlÊý¾Ý¿âlimit²éѯÓÅ»¯
MYSQLµÄÓÅ»¯ÊǷdz£ÖØÒªµÄ¡£ÆäËû×î³£ÓÃÒ²×îÐèÒªÓÅ»¯µÄ¾ÍÊÇlimit¡£mysqlµÄlimit¸ø·ÖÒ³´øÀ´Á˼«´óµÄ·½±ã£¬µ«Êý¾ÝÁ¿Ò»´óµÄʱºò£¬limitµÄÐÔÄܾͼ±¾çϽµ¡£
ͬÑùÊÇÈ¡10ÌõÊý¾Ý
select * from yanxue8_visit limit 10000,10 ºÍ
select * from yanxue8_visit limit 0,10
¾Í²»ÊÇÒ»¸öÊýÁ¿¼¶±ðµ ......
ǰ׺Ë÷Òý
(1)Èç¹ûÒÔ¶à¸ö×Ö¶Î×÷ΪË÷Òý£¨a,b£¬c)×÷Ϊһ¸ökey,ÔÚ²éѯʱ·Ö¸ù¾ÝÆ¥ÅäÇé¿öÊÇ·ñʹÓÃË÷Òý£¬ËùÒÔ£¬a/ a,b/ a,b,cÕâÑùµÄ²éѯ¶¼ÄÜʹÓõ½£¬µ«ÊÇb,a/a,c/c,aµÈ²»·û֪ǰ׺ƥÅä¾Í²»ÄÜʹÓã¬ËùÒÔÔÚдsqlʱÐèҪעÒâ
(2)¶ÔÓںܳ¤µÄ×Ö·û´®ÐèÒªÉú³Ékeyʱ£¬¿ÉÒÔÕÒ³ö×ʹÓõÄ×Ö·û´®µÄ×î³£¼ûǰ׺(Ç°N¸ö×ÖÌõ×÷Ϊkey,¶ø²»Êǽ ......
ÏÂÃæÎÒ¸ø´ó¼Ò½éÉܼ¸ÖÖÔÚmysqlÊý¾Ý¿âÖÐÐÞ¸ÄrootÃÜÂëµÄ·½·¨
·½·¨Ò»£º
ÔʼÃÜÂëÊÇ ckh
mysql -uroot -pckh
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7 to server version: 5.0.22-community-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
my ......