MYSQL¸´ÖƵļ¸ÖÖģʽ
MySQL 5.1 ÖУ¬ÔÚ¸´ÖÆ·½ÃæµÄ¸Ä½ø¾ÍÊÇÒý½øÁËеĸ´ÖƼ¼Êõ£º»ùÓÚÐеĸ´ÖÆ¡£
MYSQL¸´ÖƵļ¸ÖÖģʽ
MySQL 5.1 ÖУ¬ÔÚ¸´ÖÆ·½ÃæµÄ¸Ä½ø¾ÍÊÇÒý½øÁËеĸ´ÖƼ¼Êõ£º»ùÓÚÐеĸ´ÖÆ¡£
¼òÑÔÖ®£¬ÕâÖÖм¼Êõ¾ÍÊǹØ×¢±íÖз¢Éú±ä»¯µÄ¼Ç¼£¬¶ø·ÇÒÔÇ°µÄÕÕ³ binlog ģʽ¡£
´Ó MySQL 5.1.12 ¿ªÊ¼£¬¿ÉÒÔÓÃÒÔÏÂÈýÖÖģʽÀ´ÊµÏÖ£º
-- »ùÓÚSQLÓï¾äµÄ¸´ÖÆ(statement-based replication, SBR)£¬
-- »ùÓÚÐеĸ´ÖÆ(row-based replication, RBR)£¬
-- »ìºÏģʽ¸´ÖÆ(mixed-based replication, MBR)¡£
ÏàÓ¦µØ£¬binlogµÄ¸ñʽҲÓÐÈýÖÖ£ºSTATEMENT£¬ROW£¬MIXED¡£ MBR ģʽÖУ¬SBR ģʽÊÇĬÈϵġ£
ÔÚÔËÐÐʱ¿ÉÒÔ¶¯Ì¬µÍ¸Ä±äbinlogµÄ¸ñʽ£¬³ýÁËÒÔϼ¸ÖÖÇé¿ö£º
. ´æ´¢¹ý³Ì»òÕß´¥·¢Æ÷Öмä
. ÆôÓÃÁËNDB
. µ±Ç°»á»°ÊÔÓà RBR ģʽ£¬²¢ÇÒÒÑ´ò¿ªÁËÁÙʱ±í
Èç¹ûbinlog²ÉÓÃÁË MIXED ģʽ£¬ÄÇôÔÚÒÔϼ¸ÖÖÇé¿öÏ»á×Ô¶¯½«binlogµÄģʽÓÉ SBR ģʽ¸Ä³É RBR ģʽ¡£
. µ±DMLÓï¾ä¸üÐÂÒ»¸öNDB±íʱ
. µ±º¯ÊýÖаüº¬ UUID() ʱ
. 2¸ö¼°ÒÔÉÏ°üº¬ AUTO_INCREMENT ×Ö¶ÎµÄ±í±»¸üÐÂʱ
. ÐÐÈκΠINSERT DELAYED Óï¾äʱ
. Óà UDF ʱ
. ÊÓͼÖбØÐëÒªÇóʹÓà RBR ʱ£¬ÀýÈç´´½¨ÊÓͼÊÇʹÓÃÁË UUID() º¯Êý
É趨Ö÷´Ó¸´ÖÆģʽµÄ·½·¨·Ç³£¼òµ¥£¬Ö»ÒªÔÚÒÔÇ°É趨¸´ÖÆÅäÖõĻù´¡ÉÏ£¬ÔÙ¼ÓÒ»¸ö²ÎÊý£º
binlog_format="STATEMENT"
#binlog_format="ROW"
#binlog_format="MIXED"
µ±È»ÁË£¬Ò²¿ÉÒÔÔÚÔËÐÐʱ¶¯Ì¬ÐÞ¸ÄbinlogµÄ¸ñʽ¡£ÀýÈç
mysql> SET SESSION binlog_format = 'STATEMENT';
mysql> SET SESSION binlog_format = 'ROW';
mysql> SET SESSION binlog_format = 'MIXED';
mysql> SET GLOBAL binlog_format = 'STATEMENT';
mysql> SET GLOBAL binlog_format = 'ROW';
mysql> SET GLOBAL binlog_format = 'MIXED';
Á½ÖÖģʽ¸÷×ÔµÄÓÅȱµã£º
SBR µÄÓŵ㣺
ÀúÊ·Óƾ㬼¼Êõ³ÉÊì
binlogÎļþ½ÏС
binlogÖаüº¬ÁËËùÓÐÊý¾Ý¿â¸ü¸ÄÐÅÏ¢£¬¿ÉÒԾݴËÀ´ÉóºËÊý¾Ý¿âµÄ°²È«µÈÇé¿ö
binlog¿ÉÒÔÓÃÓÚʵʱµÄ»¹Ô£¬¶ø²»½ö½öÓÃÓÚ¸´ÖÆ
Ö÷´Ó°æ±¾¿ÉÒÔ²»Ò»Ñù£¬´Ó·þÎñÆ÷°æ±¾¿ÉÒÔ±ÈÖ÷·þÎñÆ÷°æ±¾¸ß
SBR µÄȱµã£º
²»ÊÇËùÓеÄUPDATEÓï¾ä¶¼Äܱ»¸´ÖÆ£¬ÓÈÆäÊÇ°üº¬²»È·¶¨²Ù×÷µÄʱºò¡£
µ÷ÓþßÓв»È·¶¨ÒòËØµÄ UDF ʱ¸´ÖÆÒ²¿ÉÄܳöÎÊÌâ
ʹÓÃÒÔϺ¯ÊýµÄÓï¾äÒ²ÎÞ·¨±»¸´ÖÆ£º
* LOAD_FILE()
* UUID()
* USER()
* FOUND_ROWS()
* SYSDATE() (³ý·ÇÆô¶¯Ê±ÆôÓÃÁË --sysdate-is-now Ñ¡Ïî)
INSERT ... SELECT »á²
Ïà¹ØÎĵµ£º
TomCat6.0Êý¾Ý¿âÁ¬½Ó³ØÅäÖÃʵÀý(mysqlÊý¾Ý¿â)
TomCat6.0Êý¾Ý¿âÁ¬½Ó³ØÅäÖÃÓм¸ÖÖ·½Ê½£¬ÔÚÕâÀïÎÒÖ»½éÉÜÆäÖеÄÒ»ÖÖ¹©´ó¼Ò²Î¿¼£º
ÏÂÃæÎÒ°ÑÅäÖùý³Ì·Ö³ÉÈý¸ö²½ÖèÀ´Íê³É£º
µÚÒ»²½£ºÔÚÄã°²×°TomCatµÄĿ¼ÏÂÕÒµ½context.xmlÅäÖÃÎļþ¡££¨ÀýÈ磺D:\Tomcat 6.0\conf\context.xml£©È»ºó´ò¿ªcontext.xml£¬ÔÚ±êÇ©<context>< ......
´Ómysql±¸·Ý³öÀ´µÄsqlÎļþ½øÐл¹Ô²Ù×÷ʱ±¨´í£¬²é¿´´íÎóÈÕÖ¾£¬ÄÚÈÝÈçÏ£º
Error Code: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=50913 DEFAULT CHARSET=gbk' at li ......
ǰһƪÎÄÕÂÖÐ˵µ½ÁËLOADÃüÁÕâÀï¾ÍÀ´ÏêϸµÄ¸ø×Ô¼º£¬Ë³±ãÒ²¸ø´ó¼Ò½²½âÏÂLOADÃüÁîºÍÅú´¦ÀíµÄÊý¾Ýµ¼È빦ÄÜ¡£ÓõÄʱºò¸Ð¾õMySQLÓÃÆðÀ´ÕæµÄ±È½Ï×ÌÈ󡣡£¡£¡£
Åú´¦Àíµ¼ÈëÎļþ£¬´ÓsqlÎļþµ¼ÈëÊý¾Ýµ½Êý¾Ý¿âÖÐ £¬Åú´¦ÀíÊÇÒ»Öַǽ»»¥Ê½ÔËÐÐmysql³ÌÐòµÄ·½·¨£¬ ......
Mysql Öж¨Òå×ֶκóµÄÊý¾ÝµÄÓô¦£º
int(1)ºÍint(10)ËƺõûÓÐʲô²î±ð£¬¶¼±íʾ×î´óËĸö×Ö½ÚµÄÕûÐÍÊý¾Ý¡£
ÀýÈ綨ÒåÒ»¸öÃû×ÖΪtestµÄ±í:
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
`id` int(1) NOT NULL,
`ids` int(10) default NULL,
`c` char(1) default NULL,
`cs` ......
Ëû½«¶à¸ö±íÔÚÂß¼Éϵ±×÷Ò»¸ö±íÀ´²éѯ¡£Ëû½¨Á¢ºóÓÐÁ½¸öÎļþ£¬
¡¡¡¡.frm ±í½á¹¹¶¨Òå
¡¡¡¡.mrg union±íµÄÃû×ÖÇåµ¥
¡¡¡¡Á½¸ö»ù±¾±í:
¡¡¡¡CREATE TABLE TEST_MERGE_1(
¡¡¡¡ID INT(5) NOT NULL,
¡¡¡¡VALUE VARCHAR(100) NOT NULL,
¡¡¡¡PRIMARY KEY(ID)
¡¡¡¡)
¡¡¡¡CREATE TABLE TEST_MERGE_2(
¡¡¡¡ID INT(5) NOT N ......