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.然后在一个测试机导入,跟业务,研发人员处理并确认无误后,再导入生产库
  • 相关阅读:
    利用windows 127.0.0.1:30000 代理在linux下工作
    nginx与ssh 把内网转为公网开发服务器
    php errorlog 记录
    dockerfile php 开发
    ubuntu
    k8s 1.9.1 centos7 install 离线安装
    kubernetes
    linux字符设备驱动--基本知识介绍
    linux应用程序设计--Makefile工程管理
    linux应用程序设计--GDB调试
  • 原文地址:https://www.cnblogs.com/LMySQL/p/4801107.html
Copyright © 2011-2022 走看看