MySQL·ÖÇø£¨Partition£©¹¦ÄÜÊÔÑé
MySQL·ÖÇø£¨Partition£©¹¦ÄÜÊÔÑé2008-07-06 20:02Ŀ¼
[¸ÅÊö]
[·ÖÇø±íºÍδ·ÖÇø±íÊÔÑé¹ý³Ì]
[·ÖÇøÃüÁîÏê½â]
[¸ÅÊö]
×Ô5.1¿ªÊ¼¶Ô·ÖÇø(Partition)ÓÐÖ§³Ö£¬6.0Ó¦±È½ÏÎȶ¨
= ˮƽ·ÖÇø£¨¸ù¾ÝÁÐÊôÐÔ°´Ðз֣©=
¾Ù¸ö¼òµ¥Àý×Ó£ºÒ»¸ö°üº¬Ê®Ä귢Ʊ¼Ç¼µÄ±í¿ÉÒÔ±»·ÖÇøΪʮ¸ö²»Í¬µÄ·ÖÇø£¬Ã¿¸ö·ÖÇø°üº¬µÄÊÇÆäÖÐÒ»ÄêµÄ¼Ç¼¡£
=== ˮƽ·ÖÇøµÄ¼¸ÖÖģʽ£º===
* Range£¨·¶Î§£© – ÕâÖÖģʽÔÊÐíDBA½«Êý¾Ý»®·Ö²»Í¬·¶Î§¡£ÀýÈçDBA¿ÉÒÔ½«Ò»¸ö±íͨ¹ýÄê·Ý»®·Ö³ÉÈý¸ö·ÖÇø£¬80Äê´ú£¨1980's£©µÄÊý¾Ý£¬90Äê´ú£¨1990's£©µÄÊý¾ÝÒÔ¼°ÈκÎÔÚ2000Ä꣨°üÀ¨2000Ä꣩ºóµÄÊý¾Ý¡£
* Hash£¨¹þÏ££© – ÕâÖÐģʽÔÊÐíDBAͨ¹ý¶Ô±íµÄÒ»¸ö»ò¶à¸öÁеÄHash Key½øÐмÆË㣬×îºóͨ¹ýÕâ¸öHashÂ벻ͬÊýÖµ¶ÔÓ¦µÄÊý¾ÝÇøÓò½øÐзÖÇø£¬¡£ÀýÈçDBA¿ÉÒÔ½¨Á¢Ò»¸ö¶Ô±íÖ÷¼ü½øÐзÖÇøµÄ±í¡£
* Key£¨¼üÖµ£© – ÉÏÃæHashģʽµÄÒ»ÖÖÑÓÉ죬ÕâÀïµÄHash KeyÊÇMySQLϵͳ²úÉúµÄ¡£
* List£¨Ô¤¶¨ÒåÁÐ±í£© – ÕâÖÖģʽÔÊÐíϵͳͨ¹ýDBA¶¨ÒåµÄÁбíµÄÖµËù¶ÔÓ¦µÄÐÐÊý¾Ý½øÐзָÀýÈ磺DBA½¨Á¢ÁËÒ»¸öºá¿çÈý¸ö·ÖÇøµÄ±í£¬·Ö±ð¸ù¾Ý2004Äê2005ÄêºÍ2006ÄêÖµËù¶ÔÓ¦µÄÊý¾Ý¡£
* Composite£¨¸´ºÏģʽ£© - ºÜÉñÃØ°É£¬¹þ¹þ£¬ÆäʵÊÇÒÔÉÏģʽµÄ×éºÏʹÓöøÒÑ£¬¾Í²»½âÊÍÁË¡£¾ÙÀý£ºÔÚ³õʼ»¯ÒѾ½øÐÐÁËRange·¶Î§·ÖÇøµÄ±íÉÏ£¬ÎÒÃÇ¿ÉÒÔ¶ÔÆäÖÐÒ»¸ö·ÖÇøÔÙ½øÐÐhash¹þÏ£·ÖÇø¡£
= ´¹Ö±·ÖÇø£¨°´Áз֣©=
¾Ù¸ö¼òµ¥Àý×Ó£ºÒ»¸ö°üº¬ÁË´ótextºÍBLOBÁÐµÄ±í£¬ÕâЩtextºÍBLOBÁÐÓÖ²»¾³£±»·ÃÎÊ£¬Õâʱºò¾ÍÒª°ÑÕâЩ²»¾³£Ê¹ÓõÄtextºÍBLOBÁË»®·Öµ½ÁíÒ»¸ö·ÖÇø£¬ÔÚ±£Ö¤ËüÃÇÊý¾ÝÏà¹ØÐÔµÄͬʱ»¹ÄÜÌá¸ß·ÃÎÊËٶȡ£
[·ÖÇø±íºÍδ·ÖÇø±íÊÔÑé¹ý³Ì]
*´´½¨·ÖÇø±í,°´ÈÕÆÚµÄÄê·Ý²ð·Ö
mysql> CREATE TABLE part_tab ( c1 int default NULL, c2 varchar(30) default NULL, c3 date default NULL) engine=myisam
PARTITION BY RANGE (year(c3)) (PARTITION p0 VALUES LESS THAN (1995),
PARTITION p1 VALUES LESS THAN (1996) , PARTITION p2 VALUES LESS THAN (1997) ,
PARTITION p3 VALUES LESS THAN (1998) , PARTITION p4 VALUES LESS THAN (1999) ,
PARTITION p5 VALUES LESS THAN (2000) , PARTITION p6 VALUES LESS THAN (2001) ,
PARTITION p7 VALUES LESS THAN (2002) , PARTITION p8 VALUES LESS THAN (2003) ,
PARTITION p9 VALUES LESS THAN (2004) , PARTITION p10 VALUES LESS THAN (2010),
PARTITION p11 VALUES LESS THAN MAXVAL
Ïà¹ØÎĵµ£º
½øÈëcmd
===================
1.µ¼³öÊý¾Ý¿â£¨sql½Å±¾£©
mysqldump -u Óû§Ãû -p Êý¾Ý¿âÃû > µ¼³öµÄÎļþÃû
¡¡¡¡mysqldump -u root -p db_name > test_db.sql
¡¡¡¡2.mysqlµ¼³öÊý¾Ý¿âÒ ......
·/etc/my.cnfÊÇĬÈϵÄMySQLÅäÖÃÎļþ¡£Ó¦¸Ã¶ÔÕâ¸öÎļþÅäÖÃÐ޸ġ£ËüÊÇΪѧϰĿµÄ¶øÉè¼ÆµÄ¡£
·my-small.cnfÊÇΪÁËСÐÍÊý¾Ý¿â¶øÉè¼ÆµÄ¡£²»Ó¦¸Ã°ÑÕâ¸öÄ£ÐÍÓÃÓÚº¬ÓÐһЩ³£ÓÃÏîÄ¿µÄÊý¾Ý¿â¡£
·my-medium.cnfÊÇΪÖеȹæÄ£µÄÊý¾Ý¿â¶øÉè¼ÆµÄ¡£Èç¹ûÄãÕýÔÚÆóÒµÖÐʹÓÃRHEL,¿ÉÄÜ»á±ÈÕâ¸ö²Ù×÷ϵͳµÄ×îСRAMÐèÇó(25 ......
°´ÕÕ¹Ù·½ÌṩµÄ“UCenter 1.5.0 °²×°Í¼ÎĽ̳̔£¬ÎÒ¿ªÊ¼×°ÉÏphp5,mysql5,apache2.2£¬½á¹ûÔÚhttp://127.0.0.1/ucenter/install/index.phpʱÓöµ½ÁËÁîÈËÓôÃƵÄÒ»¿Ì£¬
²é²é×ÊÁÏÒ»¿´£¬ÓкܶàÅóÓѶ¼Óöµ½ÀàËÆÇé¿ö£¬¶øÇÒÎʵÄÌû×Óµ½ÏÖÔÚ»¹Ã»Óиø»Ø£¬ÐÄÀíÄÉÃÆѽ£¬ÎªÉ¶UcenterµÄÌṩ¹«Ë¾“¿µÊ¢´´Ï딵Ŀª·¢ÈËÔ±²» ......
ÔÚmysqlÖÐÖ´ÐÐsqlÎļþ£¨Èçtest.sql£©µÄ³£Ó÷½·¨
ΪÁË·½±ã£¬¿ÉÒÔ½«mysqlµÄ°²×°Â·¾¶ÏÂbinĿ¼µÄµØÖ··Åµ½»·¾³±äÁ¿PATHÖУ¬Èç;C:\Program Files\MySQL\MySQL Server 5.0\bin¡£ÕâÑùÔÚÈÎÒâλÖôò¿ªµÄÃüÁîÐгÌÐò¶¼ÄÜÕÒµ½mysql.exe¡£
¿ÉÒÔ´ò¿ªmysqlÃüÁîÐУ¬Ò²¿ÉÒÔÔÚÃüÁîÐÐÖÐͨ¹ýmysql -u r ......
¸´ÖƼǼ,²ÉÓÃ×Ô²éѯ·½Ê½
sql
INSERT INTO `table` ('id','aa','bb','cc') SELECT 'id','aa','bb','cc' from `table` (WHERE .....)
Tips:
/**
* ¸´ÖÆмͼµÄʱºò,¿ÉÄÜÒª¸üÐÂid»òÕßÊDz¿·ÖÊý¾Ý(¼ÙÉèid×ÔÔö¼ÓµÄÇé¿ö)
*
* text_aa Ϊ¹Ì¶¨Öµ ,¿ÉÔڽű¾µ÷ÓÃÖи³±äÁ¿Öµ Èç($aa)
* ×¢Òâ'text_aa' Óë `cc` µÄÇø±ð ......