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

MySQLË÷ÒýµÄ²é¿´´´½¨ºÍɾ³ý


1£®Ë÷Òý×÷ÓÃ
ÔÚË÷ÒýÁÐÉÏ£¬³ýÁËÉÏÃæÌáµ½µÄÓÐÐò²éÕÒÖ®Í⣬Êý¾Ý¿âÀûÓø÷ÖÖ¸÷ÑùµÄ¿ìËÙ¶¨Î»¼¼Êõ£¬Äܹ»´ó´óÌá¸ß²éѯЧÂÊ¡£ÌرðÊǵ±Êý¾ÝÁ¿·Ç³£´ó£¬²éѯÉæ¼°¶à¸ö±íʱ£¬Ê¹ÓÃË÷ÒýÍùÍùÄÜʹ²éѯËٶȼӿì³ÉǧÉÏÍò±¶¡£
ÀýÈ磬ÓÐ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×Ó¾äÏàÅäµÄÄÇЩÐС£¶ø¿ÉÄܵÄ×éºÏÊýĿΪ1000×1000×1000£¨Ê®ÒÚ£©£¬ÏÔÈ»²éѯ½«»á·Ç³£Âý¡£
Èç¹û¶Ôÿ¸ö±í½øÐÐË÷Òý£¬¾ÍÄܼ«´óµØ¼ÓËÙ²éѯ½ø³Ì¡£ÀûÓÃË÷ÒýµÄ²éѯ´¦ÀíÈçÏ¡£
£¨1£©´Ó±ít1ÖÐÑ¡ÔñµÚÒ»ÐУ¬²é¿´´ËÐÐËù°üº¬µÄÊý¾Ý¡£
£¨2£©Ê¹Óñít2ÉϵÄË÷Òý£¬Ö±½Ó¶¨Î»t2ÖÐÓët1µÄֵƥÅäµÄÐС£ÀàËÆ£¬ÀûÓñít3ÉϵÄË÷Òý£¬Ö±½Ó¶¨Î»t3ÖÐÓëÀ´×Ôt1µÄֵƥÅäµÄÐС£
£¨3£©É¨Ãè±ít1µÄÏÂÒ»Ðв¢Öظ´Ç°ÃæµÄ¹ý³Ì£¬Ö±µ½±éÀút1ÖÐËùÓеÄÐС£
ÔÚ´ËÇéÐÎÏ£¬ÈÔÈ»¶Ô±ít1Ö´ÐÐÁËÒ»¸öÍêȫɨÃ裬µ«Äܹ»ÔÚ±ít2ºÍt3ÉϽøÐÐË÷Òý²éÕÒÖ±½ÓÈ¡³öÕâЩ±íÖеÄÐУ¬±ÈδÓÃË÷ÒýʱҪ¿ìÒ»°ÙÍò±¶¡£
ÀûÓÃË÷Òý£¬MySQL¼ÓËÙÁËWHERE×Ó¾äÂú×ãÌõ¼þÐеÄËÑË÷£¬¶øÔÚ¶à±íÁ¬½Ó²éѯʱ£¬ÔÚÖ´ÐÐÁ¬½Óʱ¼Ó¿ìÁËÓëÆäËû±íÖеÄÐÐÆ¥ÅäµÄËٶȡ£
2.  ´´½¨Ë÷Òý
ÔÚÖ´ÐÐCREATE TABLEÓï¾äʱ¿ÉÒÔ´´½¨Ë÷Òý£¬Ò²¿ÉÒÔµ¥¶ÀÓÃCREATE INDEX»òALTER TABLEÀ´Îª±íÔö¼ÓË÷Òý¡£
1£®ALTER TABLE
ALTER TABLEÓÃÀ´´´½¨ÆÕͨË÷Òý¡¢UNIQUEË÷Òý»òPRIMARY KEYË÷Òý¡£
 
ALTER TABLE table_name ADD INDEX index_name (column_list)
ALTER TABLE table_name ADD UNIQUE (column_list)
ALTER TABLE table_name ADD PRIMARY KEY (column_list)
 
ÆäÖÐtable_nameÊÇÒªÔö¼ÓË÷ÒýµÄ±íÃû£¬column_listÖ¸³ö¶ÔÄÄЩÁнøÐÐË÷Òý£¬¶àÁÐʱ¸÷ÁÐÖ®¼äÓöººÅ·Ö¸ô¡£Ë÷ÒýÃûindex_name¿ÉÑ¡£¬È±Ê¡Ê±£¬MySQL½«¸ù¾ÝµÚÒ»¸öË÷ÒýÁи³Ò»¸öÃû³Æ¡£ÁíÍ⣬ALTER TABLEÔÊÐíÔÚµ¥¸öÓï¾äÖиü¸Ä¶à¸ö±í£¬Òò´Ë¿ÉÒÔÔÚͬʱ´´½¨¶à¸öË÷Òý¡£
2£®CREATE INDEX
CREATE INDEX¿É¶Ô±íÔö¼ÓÆÕͨË÷Òý»òUNIQUEË÷Òý¡£
 
CREATE INDEX index_name ON table_name (column_list)
CREATE UNIQUE INDEX index_name ON table_name (column_list)
 
table_name¡¢index_nameºÍcolumn_list¾ßÓÐÓëALTER TABLEÓï¾äÖÐÏàͬµÄº¬Ò壬Ë÷ÒýÃ


Ïà¹ØÎĵµ£º

MYSQL·þÎñÎÞ·¨Æô¶¯1067½â¾ö°ì·¨


ÔÚÔËÐÐmysql administratorµÄʱºò,ÎÞ·¨µÇ¼mysql·þÎñÆ÷,²éÕÒ´íÎó,ÀÏÊÇÎÞ·¨½øÐÐ.ÔÚ½øÈëwindowsϵĹÜÀí¹¤¾ßµÄ·þÎñÖÐ,ÒÀÈ»ÎÞ·¨Æô¶¯,Ìáʾ˵ÊÇ´íÎó1067.½â¾ö·½°¸ÈçÏÂ:
1\½øÈëÃüÁîÌáʾ·û,ÊäÈë sc delete mysql
ÌáʾÈôÊÇdelete service success,Ö¤Ã÷ɾ³ý·þÎñ³É¹¦;
2\ÔËÐÐmysqlµÄbinĿ¼ÏÂÃæµÄmysqlinstanceconfig,¶Ômysql½øÐ ......

VB6.0ÈçºÎÓà libmySQL.dll API·ÃÎÊMYSQLÊý¾Ý¿â

MYSQL Ó¦ÓÃÊ®·Ö¹ã·¶£¬ºÜ¶àÍøÕ¾¼¸ºõ¶¼ÔÚÓÃËû£¬ÒòΪËûµÄСÇɺÍÁé»îÐԵȷ½ÃæÈÃÎÒ¾ö¶¨Òª¶ÔËû½øÐÐÑо¿£¬µ½ÏÖÔÚÒѾ­³É¹¦µÄ²»Óþ­¹ýODBC£¬ADOµÈ·½Ê½¾Í¿ÉÒÔ¶ÁÈ¡ºÍ¸üÐÂÊý¾Ý¡£
 
ºÃÁ˲»¶àÂÞ࣬ÒÔÏÂÎÒÀ´½éÉÜ×ܸö³ÌÐòµÄϸ½Ú:
 
£¨Ò»£©APIÉùÃ÷
 
1.  '·ÖÅä»ò³õʼ»¯ÊʺÏmysql_real_connect()µÄÒ»¸öMYSQL¶ÔÏñ¡ ......

¹ØÓÚMySQLÊý¾Ý¿âµÄ´æ´¢ÒýÇæ

MySQLÖеÄÊý¾ÝÓø÷ÖÖ²»Í¬µÄ¼¼Êõ´æ´¢ÔÚÎļþ(»òÕßÄÚ´æ)ÖС£ÕâЩ¼¼ÊõÖеÄÿһÖÖ¼¼Êõ¶¼Ê¹Óò»Í¬µÄ´æ´¢»úÖÆ¡¢Ë÷Òý¼¼ÇÉ¡¢Ëø¶¨Ë®Æ½²¢ÇÒ×îÖÕÌṩ¹ã·ºµÄ²»Í¬µÄ¹¦ÄܺÍÄÜÁ¦¡£Í¨¹ýÑ¡Ôñ²»Í¬µÄ¼¼Êõ£¬ÄãÄܹ»»ñµÃ¶îÍâµÄËٶȻòÕß¹¦ÄÜ£¬´Ó¶ø¸ÄÉÆÄãµÄÓ¦ÓõÄÕûÌ幦ÄÜ¡£
ÀýÈ磬Èç¹ûÄãÔÚÑо¿´óÁ¿µÄÁÙʱÊý¾Ý£¬ÄãÒ²ÐíÐèҪʹÓÃÄÚ´æ´æ´¢ÒýÇæ¡£ÄÚ´æ´æ´ ......

Solaris10ÏÂmysqlµÄ±àÂëÎÊÌâ

°²×°ºó
/etc/init.d/mysql start (stop) ΪÆô¶¯ºÍÍ£Ö¹·þÎñÆ÷
/etc/mysql/ Ö÷ÒªÅäÖÃÎļþËùÔÚλÖà my.cnf
/var/lib/mysql/ ·ÅÖõÄÊÇÊý¾Ý¿â±íÎļþ¼Ð£¬ÕâÀïµÄmysqlÏ൱ÓÚwindowsÏÂmysqlµÄdateÎļþ¼Ð
Æô¶¯mysqlºó£¬ÒÔrootµÇ¼mysql
isher@isher-ubuntu:~$ mysql -u root
>show variables like 'character%'; #Ö´ÐбàÂëÏ ......

MySQLÖظ´¼Ç¼ ²éѯ¼°É¾³ý

²éѯ¼°É¾³ýÖظ´¼Ç¼µÄ·½·¨
(Ò»)
1¡¢²éÕÒ±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´ÅжÏ
select * from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
2¡¢É¾³ý±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´Åжϣ¬Ö»Á ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ