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

¸ßÐÔÄÜMySqlѧϰ±Ê¼Ç(Ò»)

¸ßÐÔÄÜMySqlѧϰ±Ê¼Ç
1.Õë¶ÔÓ¦Óý¨Á¢×Ô¼ºµÄË÷Òý
URL²éÕÒÀý×Ó
    select * from tUrl where url='http://www.163.com';
ÒÔurl£¨×Ö·û´®£©×÷ÐÐΪË÷Òý»áʹµÃ×÷ΪË÷Òý½á¹¹µÄB-Tree±ä´ó£¬¿ÉÒÔÒƳýurlÁÐÉϵÄË÷Òý£¬²¢Ìí¼ÓÒ»¸öurl_crcË÷ÒýÁУ¬
ÏȽ¨Á¢±í£º
create tables tUrl(
    id int unsigned NOT NULL auto_increment,
    url varchar(255) NOT NULL,
    url_crc int unsigned NOT NULL DEFAULT 0,
    primary key(id)
);
ͨ¹ýÒÔÏ·½Ê½²éѯ£º
    mysql> select * from queryHash where url_crc=CRC32( 'http://www.163.com' ) and url='http://www.163.com' ; 
1.url_crcÁеÄË÷ÒýÐÔÄܽϸß
2.ÔÚÓгåÍ»µÄʱºò£¬ÔÙͨ¹ý¾«È·±È½ÏµÃµ½ËùÐèÒªÁÐ
3.Èç¹û³åÍ»¹ý¶à¿ÉÒÔ¸ÄÓÉ64λµÄhash, MD5()/SHA1(), ½ØÈ¡Ç°16ʾÀýÈçÏ£º
  mysql> select conv( right ( md5('http://www.csdn.net'), 16), 16, 10) as hash64;
select conv( right ( md5('http://www.csdn.net'), 16), 16, 10) as hash64;
+---------------------+
| hash64              |
+---------------------+
| 9270541833456602998 |
+---------------------+
×¢£ºMaatkit( http://www.maatkit.org/)°üº¬ÁËÒ»¸öÓû§×Ô¶¨Ò庯Êý(UDF)£¬ÊµÏÖÁËFowler/Noll/Vo64λ¹þÏ£º¯Êý£¬Ëٶȷdz£¿ì¡£
ÉÏÊö·½·¨È±µãÊÇÒªÊÖ¹¤Î¬»¤hashÖµ£¬¿ÉÒÔͨ¹ýʹÓô¥·¢Æ÷ά»¤,·Ö±ðΪinsert/updateÌí¼Ó´¥·¢Æ÷£º
delimiter |
create trigger url_crc_ins before insert on tUrl for each row begin
set NEW.url_crc=crc32(NEW.url);
end;
|
create trigger url_crc_upd before update on tUrl for each row begin
set NEW.url_crc=crc32(NEW.url);
end;
|
delimiter ;
Ñé֤һϣº
 
mysql> insert into tUrl(url) values( 'http://www.csdn.net' );
mysql> select * from tUrl;
+----+---------------------+------------+
| id | url                 | url_crc    |
+----+---------------------+------------+
|  2 | http://www.csdn.net | 3


Ïà¹ØÎĵµ£º

MySQL Ãâ°²×°°æÅäÖÃ

1.ÏÂÔØ MySQL 6.0Ãâ°²×°°æ
http://www.mysql.com/downloads/mirror.php?id=386828
2.½« MySQL6.0 ½âѹµ½´ý°²×°Ä¿Â¼(×Ô¼º¾ö¶¨·Åµ½ÄÄ£©¡£½âѹºóĬÈÏÎļþ¼ÐÃû³ÆΪ£ºmysql£¨µ±È»¿ÉÒÔ×Ô¼º¸ü¸Ä£©£¬È»ºóÔÚ»·¾³±äÁ¿ÖÐÉèÖÃMYSQL_HOME£¨ÕâÑù£¬ÒÔºó¿ÉÒÔÓÃ%MYSQL_HOME%ÒýÓð²×°Ä¿Â¼£©¡£È磬ÎÒ·ÅÔÚEÅ̸ùĿ¼Ï£¬ËùÒÔ£¬MYSQL_HOMEÉèÖÃΪ ......

ÐÞ¸ÄMYSQLµÄinnodb_log_file_sizeµ¼ÖµÄMYSQL±ÀÀ£


ÕâÁ½ÌìÕýÔÚ²âMYSQLµÄÐÔÄÜ£¬°´ÕÕMYSQLÎĵµÖÐÍƼöµÄÉèÖã¬ÐÞ¸ÄÁ˼¸¸öϵͳ±äÁ¿
innodb_buffer_pool_size=1G
innodb_log_file_size=250M
innodb_log_buffer_size=8M
½á¹ûMYSQL±ÀÁË¡£mysql¿Í»§¶ËÄܵǼ£¬µ«Ö»ÒªÖ´ÐÐÈκÎÃüÁmysqldÁ¢¿Ì±Àµô¡£
¿ªÊ¼»¹ÒÔΪÊÇinnodb_buffer_pool_sizeµÈ¼¸¸ö²ÎÊýÉèµÃÌ«´óÁË£¬¿ÉÊǵ÷ÕûÁ˼¸´Î¶ ......

MysqlÖ¸Á showÓ÷¨

MySQL showµÄÓ÷¨
   
a. show tables»òshow tables from database_name; // ÏÔʾµ±Ç°Êý¾Ý¿âÖÐËùÓбíµÄÃû³Æ
   b. show databases; // ÏÔʾmysqlÖÐËùÓÐÊý¾Ý¿âµÄÃû³Æ
   c. show columns from table_name from database_name; »òshow columns from database_name.table_name;  ......

Á˽âMySQLÊý¾Ý¿âËø¶¨»úÖÆ

Èç¹ûÒªÁ˽âMySQLÊý¾Ý¿âËø¶¨»úÖÆ£¬Ê×ÏÈÁ˽âÒ»ÏÂMySQLµÄÈýÖÖËø¶¨ÀàÐÍ£º
Ò»£¬Ðм¶Ëø¶¨
¶þ£¬±í¼¶Ëø¶¨
Èý£¬Ò³¼¶Ëø¶¨
ÕâÈýÖÖËø¶¨ÀàÐÍ£¬ÔÚMySQLÊý¾Ý¿âÖÐʹÓÃÈçÏ£º
Ðм¶Ëø¶¨£ºMyISAM£¬Memory£¬CSV[·ÇÊÂÎñÐԵĴ洢ÒýÇæ]
±í¼¶Ëø¶¨£ºInnoDB£¬NDB Chuster
Ò³¼¶Ëø¶¨£ºBerkeley DB
Á½ÖÖËø¶¨»úÖÆ£º¶ÁËø¶¨ºÍдËø¶¨
MySQLÊý¾Ý¿âËø¶ ......

MySQLÈçºÎÀûÓÃË÷ÒýÓÅ»¯ORDER BYÅÅÐòÓï¾ä


MySQLË÷Òýͨ³£ÊDZ»ÓÃÓÚÌá¸ßWHEREÌõ¼þµÄÊý¾ÝÐÐÆ¥Åä»òÕßÖ´ÐÐÁª½á²Ù×÷ʱƥÅäÆäËü±íµÄÊý¾ÝÐеÄËÑË÷Ëٶȡ£
MySQLÒ²ÄÜÀûÓÃË÷ÒýÀ´¿ìËÙµØÖ´ÐÐORDER BYºÍGROUP BYÓï¾äµÄÅÅÐòºÍ·Ö×é²Ù×÷¡£
ͨ¹ýË÷ÒýÓÅ»¯À´ÊµÏÖMySQLµÄORDER BYÓï¾äÓÅ»¯£º
1¡¢ORDER BYµÄË÷ÒýÓÅ»¯¡£Èç¹ûÒ»¸öSQLÓï¾äÐÎÈ磺
SELECT [column1],[column2],…. fro ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ