• my21_myloader -o参数


    -o 参数

    如果不使用-o参数,遇到第一个有主键或者唯一约束的数据,则退出当前线程;如果有-o参数,则删除原来的表,创建新表,再插入数据,主键不会发生变化。

    ** Message: Dropping table or view (if exists) `maell`.`bootrap`
    ** Message: Creating table `maell`.`bootrap`

    mysql -uautomng -prootroot -h127.0.0.1
    mkdir -p /data/tmp/table
    mydumper -u automng -p rootroot -h 127.0.0.1 -P 3306 -B vodb -T test -e -o /data/tmp/table

    mysql> select * from test;
    +------+--------+---------+------------------------+---------------------+
    | tid | tname | test_id | tvalue | CreateTime |
    +------+--------+---------+------------------------+---------------------+
    | 2 | aaabbb | 3 | 有张有驰有分寸2 | 2018-11-17 21:39:58 |
    | 3 | aaabbb | 4 | 有张有驰有分寸3 | 2018-11-17 21:39:58 |
    | 4 | aaabbb | 5 | 有张有驰有分寸4 | 2018-11-17 21:39:58 |
    +------+--------+---------+------------------------+---------------------+
    3 rows in set (0.00 sec)

    删除、更新、插入各一条记录
    mysql> delete from test where tid=2;
    Query OK, 1 row affected (0.06 sec)

    mysql> insert into test (tid,tname) values (1,'123');
    Query OK, 1 row affected (0.09 sec)

    mysql> update test set tid=4 where tvalue='wa ka ka';
    Query OK, 0 rows affected (0.00 sec)
    Rows matched: 0 Changed: 0 Warnings: 0

    mysql> select * from test;
    +------+--------+---------+------------------------+---------------------+
    | tid | tname | test_id | tvalue | CreateTime |
    +------+--------+---------+------------------------+---------------------+
    | 3 | aaabbb | 4 | 有张有驰有分寸3 | 2018-11-17 21:39:58 |
    | 4 | aaabbb | 5 | 有张有驰有分寸4 | 2018-11-17 21:39:58 |
    | 1 | 123 | 7 | NULL | 2019-01-09 18:55:19 |
    +------+--------+---------+------------------------+---------------------+
    3 rows in set (0.00 sec)


    导入,没有-o参数,默认开启四线程,表存在时重新插入数据,在遇到第一条重复数据时报错并退出当前线程;原有库数据不会发生变化
    myloader -u automng -p rootroot -h 127.0.0.1 -P 3306 -B vodb -d /data/tmp/table -v 3

    # myloader -u automng -p rootroot -h 127.0.0.1 -P 3306 -B vodb -d /data/tmp/table -v 3
    ** Message: 4 threads created
    ** Message: Creating table `vodb`.`test`

    ** (myloader:23544): CRITICAL **: Error restoring vodb.test from file vodb.test-schema.sql: Table 'test' already exists
    ** Message: Thread 1 restoring `vodb`.`test` part 0
    ** Message: Thread 2 shutting down
    ** Message: Thread 3 shutting down
    ** Message: Thread 4 shutting down

    ** (myloader:23544): CRITICAL **: Error restoring vodb.test from file vodb.test.sql: Duplicate entry '4' for key 'PRIMARY'
    ** Message: Thread 1 shutting down


    -o则是将原来数据清除,然后再插入,导入后的结果与备份的原数据一致
    myloader -u automng -p rootroot -h 127.0.0.1 -P 3306 -B vodb -d /data/tmp/table -o -v 3

    mysql> select * from test;
    +------+--------+---------+------------------------+---------------------+
    | tid | tname | test_id | tvalue | CreateTime |
    +------+--------+---------+------------------------+---------------------+
    | 2 | aaabbb | 3 | 有张有驰有分寸2 | 2018-11-17 21:39:58 |
    | 3 | aaabbb | 4 | 有张有驰有分寸3 | 2018-11-17 21:39:58 |
    | 4 | aaabbb | 5 | 有张有驰有分寸4 | 2018-11-17 21:39:58 |
    +------+--------+---------+------------------------+---------------------+
    3 rows in set (0.00 sec)

  • 相关阅读:
    20.11.16 leetcode406 leetcode中的排序写法
    20.11.15 leetcode402
    20.11.14 leetcode1122(自定义排序)
    polyline NOIP模拟 数论 规律
    alien NOIP模拟 位运算 数论
    跳石头 vijos1981 NOIP2015 D2T1 二分答案 模拟 贪心
    寻找道路 vijos1909 NOIP2014 D2T2 SPFA
    不死的LYM NOIP模拟 二分+状压DP
    死亡的颂唱者 NOIP模拟 贪心 DFS
    无线网络发射器选址 vijos 1908 NOIP2014 D2T1 模拟
  • 原文地址:https://www.cnblogs.com/perfei/p/10246293.html
Copyright © 2020-2023  润新知