ͨ¹ý·ÖÇø£¨Partition£©ÌáÉýMySQLÐÔÄÜ
ͨ¹ý·ÖÇø£¨Partition£©ÌáÉýMySQLÐÔÄÜ
×÷Õߣºfoxcai À´Ô´:foxcai µÄ Blog (2006-05-08 14:30:34)
ͨ¹ý·ÖÇø£¨Partition£©ÌáÉýMySQLÐÔÄÜ
——MySQL5.1ÐÂÌØÐÔ·ÒëϵÁÐ
¼¸ÄêÇ°£¬°³Ð´¹ýһƪÌâΪ“The Foundation of Excellent Performance”µÄÎÄÕÂ(ÏÖÔÚÈÔÈ»¿ÉÒÔÔÚhttp://www.tdan.com/i016fe03.htm¿´µ½)£¬°³¶ÔSQLÓï¾äÊÇÓ°ÏìÊý¾Ý¿âÇý¶¯ÏµÍ³ÐÔÄܵĵÚÒ»ÒªËصĹ۵ãÓеãÖÊÒÉ¡£ÆäʵÔÚÄÇʱÎÒÔÚÎÄÕÂÖоͼáÐÅÊý¾Ý¿âµÄÎïÀíÉè¼ÆÔڶԸ߼¶Êý¾Ý¿âµÄÐÔÄÜÓ°ÏìÉÏÔ¶±ÈÆäËûÒòËØÖØÒª¡£Í¬Ê±°³»¹¸ø´ó¼Ò¿´ÁËOracleµÄÑо¿£¬ËûÃǽâÊÍÁËΪʲô׾ÁÓµÄÎïÀíÉè¼ÆÊÇÊý¾Ý¿âÍ£»ú£¨ÎÞÂÛÊÇÓмƻ®µÄ»¹ÊÇû¼Æ»®µÄ£©±³ºóµÄÖ÷ÒªÔÒò¡£Õâô¶àÄ궼¹ýÀ´À²£¨ÐÒºÃû¶àÉÙÈ˳¯°³ÈÓשͷ£©£¬°³µÄ¹ÛµãÊǸıäÁËһЩ£¬µ«ÔÚÕâµãÉÏ°³»¹ÊǼá³ÖDBAÈç¹ûÏëÒª¸ßÐÔÄܵÄÊý¾Ý¿â¾Í±ØÐëÔÚÊý¾Ý¿âµÄÎïÀíÉè¼ÆÉ϶à˼¿¼µÄ¹Ûµã£¬ÕâÑù²ÅÄܼõÉÙÏìӦʱ¼äʹÖÕ¶ËÓû§ÂúÒâ¶ø²»ÊÇÒýÀ´ÂîÉùһƬ¡££¨³ÂÅóÞÈÓ²»ÒªÄÇôÑÏË࣬ºÙºÙ£©
°³½ñÌìÕâô¼¤¶¯ÓÖÏëдÎÄÕµÄÔÒòÊÇMySQL5.1µÄ·¢²¼´øÀ´ÁËÉè¼Æ³¬Ç¿¶¯Á¦Êý¾Ý¿âµÄÇ¿ÓÐÁ¦µÄÎäÆ÷£¬ÈκÎMySQLµÄDBA¶¼Ó¦¸Ã¾¡¿ìѧϰ²¢Ê¹ÓÃËü¡£°³¾õµÃÈç¹ûÄܺܺõÎʹÓÃÕâ¸ö5.1°æ´øÀ´µÄÐÂÌØÐÔ£¬DBA¿ÉÒÔʹ×Ô¼º¹ÜÀíµÄVLDB£¨²»ÖªµÀʲôÊÇVLDB£¿¸æËßÄ㣬ÊǺôóºÃ´óµÄÊý¾Ý¿âµÄÒâ˼£¬Very Large DB£©»òÊý¾Ý²Ö¿âÆæ¼£°ãµÄ»ñµÃ¾Þ´óµÄÐÔÄÜÌáÉý¡£
ʲôÊÇÊý¾Ý¿â·ÖÇø£¿
Êý¾Ý¿â·ÖÇøÊÇÒ»ÖÖÎïÀíÊý¾Ý¿âÉè¼Æ¼¼Êõ£¬DBAºÍÊý¾Ý¿â½¨Ä£ÈËÔ±¶ÔÆäÏ൱ÊìϤ¡£ËäÈ»·ÖÇø¼¼Êõ¿ÉÒÔʵÏֺܶàЧ¹û£¬µ«ÆäÖ÷ҪĿµÄÊÇΪÁËÔÚÌض¨µÄSQL²Ù×÷ÖмõÉÙÊý¾Ý¶ÁдµÄ×ÜÁ¿ÒÔËõ¼õÏìӦʱ¼ä¡£
·ÖÇøÖ÷ÒªÓÐÁ½ÖÖÐÎʽ£º//ÕâÀïÒ»¶¨Òª×¢ÒâÐкÍÁеĸÅÄrowÊÇÐУ¬columnÊÇÁУ©
ˮƽ·ÖÇø£¨Horizontal Partitioning£© ÕâÖÖÐÎʽ·ÖÇøÊǶԱíµÄÐнøÐзÖÇø£¬Í¨¹ýÕâÑùµÄ·½Ê½²»Í¬·Ö×éÀïÃæµÄÎïÀíÁзָîµÄÊý¾Ý¼¯µÃÒÔ×éºÏ£¬´Ó¶ø½øÐиöÌå·Ö¸î£¨µ¥·ÖÇø£©»ò¼¯Ìå·Ö¸î£¨1¸ö»ò¶à¸ö·ÖÇø£©¡£ËùÓÐÔÚ±íÖж¨ÒåµÄÁÐÔÚÿ¸öÊý¾Ý¼¯Öж¼ÄÜÕÒµ½£¬ËùÒÔ±íµÄÌØÐÔÒÀÈ»µÃÒÔ±£³Ö¡£
¾Ù¸ö¼òµ¥Àý×Ó£ºÒ»¸ö°üº¬Ê®Ä귢Ʊ¼Ç¼µÄ±í¿ÉÒÔ±»·ÖÇøΪʮ¸ö²»Í¬µÄ·ÖÇø£¬Ã¿¸ö·ÖÇø°üº¬µÄÊÇÆäÖÐÒ»ÄêµÄ¼Ç¼¡££¨ÅóÞÈ×¢£ºÕâÀï¾ßÌåʹÓõķÖÇø·½Ê½ÎÒÃǺóÃæÔÙ˵£¬¿ÉÒÔÏÈ˵һµã£¬Ò»¶¨ÒªÍ¨¹ýij¸öÊôÐÔÁÐÀ´·Ö¸î£¬Æ©ÈçÕâÀïʹÓõÄÁоÍÊÇÄê·Ý£©
´¹Ö±·ÖÇø£¨Vertical Partitioning£© ÕâÖÖ·ÖÇø·½Ê½Ò»°ãÀ´ËµÊÇͨ¹ý¶Ô±í
Ïà¹ØÎĵµ£º
¾³£Óõ½£¬µ«ÊÇ×ÜÊǼDz»×¡¡£
Óï·¨ÈçÏ£º
ALTER TABLE JOB ADD CONSTRAINT fk_prono
FOREIGN KEY(PRONO)
REFERENCES PROJECT(PRONO)
ON DELETE CASCADE
ON UPDATE NO ACTION;
ÎÒÔÚmysqlÖÐÌí¼ÓÁËÍâ¼üÔ¼Êø£¬ÊÔÁË°ëÌìû³É¹¦£¬ºóÀ´°ÑÍâ¼üµÄÃû×ÖÓÉFK¸Ä³ÉFK_1¾ÍºÃÁË£¬¿ÉÄÜmysqlÖÐFKÊǸö±£Áô×Ö£¬×¢Ò⣡ ......
--default-character-set=utf8 ÓëÐÞ¸ÄsqlÎļþ¼ÓÈ룺SET NAMES 'utf8';
µ¼Èë½Å±¾Ê±£¬SET NAMES 'xxx' £¬xxxÓ¦¸ÃºÍsql½Å±¾ÎļþµÄʵ¼Ê±àÂëÒ»Ö£¬Èç¹ûÄãÉèÖõÄʱutf-8 £¬ÄÇôÇëÈ·ÈÏÄãµÄsql½Å±¾Îļþʱutf-8±£´æµÄ:
iconv -f UTF-8 xxx.sql
Èç¹ûÏÔʾÕý³££¬ÄÇôÕâÒ»²½¾ÍOKÁË
ÁíÍâ×¢ÒâÄãµÄ½Å±¾ÀÓÐûÓиø¿â±íÉèÖ ......
ºÜ¾ÃûÓÐÓÃMysqlÁË£¬·¢ÏÖССµÄʱ¼äÎÊÌâÒ²Óöµ½²»ÉÙÂé·³£¬ºÇºÇ
ËùÒÔ×ܽáһϣº
µÚÒ»ÖÖ:
Date time= new java.sql.Date(new java.util.Date().getTime());
µÚ¶þÖÖ:
java ÓÃPreparedStatementÀ´setDate,ÓÃÎʺŵÄÐÎʽ¸øÈÕÆÚÎʺŸ³Öµ
pstmt.setTimestamp(8, new Timestamp(System.currentTimeMillis()));
pst ......
Java ¶ÁÈ¡ MySQL ÖÐÎÄ ÂÒÂë
³¡¾°:Java,eclipse£¬¶ÁÈ¡MySQLÊý¾Ý¿â£¬MySQL±àÂëΪutf-8
ÎÊÌ⣺¶Á³öÀ´µÄÖÐÎÄÔÚeclipseµÄÊä³ö´°¿ÚÖÐÏÔʾΪÂÒÂë
´íÎóµÄд·¨
1
System.out.print(new String( rs.getString("bib_author").getBytes("utf-8"),"GBK" ));
2
System.out.print( ......
linux:
Èç¹û MySQL ÕýÔÚÔËÐУ¬Ê×ÏÈɱ֮£º killall -TERM mysqld¡£
Æô¶¯ MySQL £º/usr/bin/safe_mysqld --skip-grant-tables &
¾Í¿ÉÒÔ²»ÐèÒªÃÜÂë¾Í½øÈë MySQL ÁË¡£
È»ºó¾ÍÊÇ
>use mysql
>update user set password=password("new_pass") where user="root";
>flush privileges;
ÖØÐÂɱ MySQL £¬ ......