zoukankan      html  css  js  c++  java
  • 从整库逻辑备份单独抽出一张表

    前言:有时候因应用端有高权限的人员误操作,影响到的表只有一张,那么我们只要在前一天的备份里面一张表的数据,如果一个库表很多很大,异地恢复整个库,撇开机器性能不说,时间就浪费了。接下来说一下怎么抽取单张表内容。
     
    原理:简单的说指定库名导出,mysqldump是按show tables顺序导出,你要抽取哪个表,就是要知道你下一个表名,把这段内容全部抽取出来就对了
    1.确认你要导出的表名并查找出下一个表的表名字 cat xxxx.sql | grep "^-- Table structure for table" | grep -A 1 "aaa_opp" 
     
    [root@web10 247_2015-09-03]# cat xxxx.sql | grep "^-- Table structure for table" | grep -A 1 "aaa_opp"
    -- Table structure for table `aaa_opp`
    -- Table structure for table `aaa_opp_copy`
    -- Table structure for table `aaa_opp_update_history`
    -- Table structure for table `aaa_org_region`
    2.将你要抽出的表(aaa_ppp),(aaa_opp_copy)之间内容打印出来 sed -n "/^-- Table structure for table \`aaa_opp\`/,/^-- Table structure for table \`aaa_opp_copy\`/p"  xxxx.sql > temp.sql
    3.然后在一个测试机导入,跟业务,研发人员处理并确认无误后,再导入生产库
  • 相关阅读:
    node递归批量重命名指定文件夹下的文件
    nvm
    node在Web中的用途
    给flash续命(rtmp/http-flv网页播放器)
    AMR/PCM格式语音采集/编码/转码/解码/播放
    视频分析,目标跟踪应用方案梳理
    srs-librtmp pusher(push h264 raw)
    srs
    nginx-rtmp/http-flv
    Introduction to Sound Programming with ALSA
  • 原文地址:https://www.cnblogs.com/LMySQL/p/4801107.html
Copyright © 2011-2022 走看看