复制中临时表的运用TIPS_MySQL

WBOY
Release: 2016-06-01 13:40:47
Original
878 people have browsed it

bitsCN.com
复制中临时表的运用TIPS 我们知道,临时表有以下特性:1. SESSION 级别,SESSION 一旦断掉,就被自动DROP 了。2. 和默认引擎有关。如果默认引擎是INNODB,而你又疯狂的使用临时表。那么,你的IBDATA会被无限的增大。3. 和磁盘表一样,默认写入到binlog, 而且被动的加入了rollback 计划。 幻想如下场景:数据库损坏,也没有备份。刚好二进制日志全部保存完好,幸福了。导入二进制日志到MYSQL。
有两种方法: 1) mysqlbinlog ..... *.log | mysql dbname; 这种利用管道直接恢复数据,时间短,效率高。 可里面如果有一堆的临时表,而且刚好在日志的中间,那么悲剧了, 导入失败。 (回想临时表的特性就知道了。) 2) mysqlbinlog ..... *.log > result.log;mysql dbname [sql] SET SQL_LOG_BIN=0; 关掉SESSION级别的复制。 update tmp_t1, tmp_t2 set ....; drop tmp_t1; drop tmp_t2; SET SQL_LOG_BIN=1; 打开SESSION级别的复制。
bitsCN.com

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!