zoukankan      html  css  js  c++  java
  • Mysql——查询语句备份

        echo "++++++ modify log_uid start ++++++"

        mysql -h$targetIp -uroot codex_log_operation -Bse "show tables;"

        | xargs -I "{}" mysql -h$targetIp -uroot codex_log_operation -e

        "alter table {} modify log_uid varchar(128) NOT NULL;

         alter table {} modify account_id bigint(64);

         select concat(server_id, '_', log_uid) from {} limit 0;

         update {} set  log_uid = concat(server_id, '_', log_uid) where length(0+log_uid)=length(log_uid);"

        echo "++++++ modify log_uid end ++++++"

     

     

     

     

    select "重置id...";

    drop procedure if exists `resetId`;

    delimiter $$

    create procedure  resetId(In targetTabName varchar(200))

    begin

    select targetTabName, @baseId;

     

    set @sqlStr=CONCAT('delete from  ', targetTabName,  ' where roleId not in (select id from role)');

            PREPARE stmt from @sqlStr;

            EXECUTE stmt;

            DEALLOCATE PREPARE stmt;

     

    set @sqlStr=CONCAT('update ', targetTabName, ' set id= id%(1<<42) +', @baseId, ', roleId= roleId%(1<<42) +', @baseId);

    PREPARE stmt from @sqlStr;

    EXECUTE stmt;

    DEALLOCATE PREPARE stmt;

     

    commit;

    end$$

    delimiter ;

     

    SET @baseId=0;

    select id, (id>>47)%(1<<11)%100, (id>>47)%(1<<11), id%(1<<42), @baseId:=(id-id%(1<<42)) from server limit 1;

    select @baseId;

     

    call resetId('activity_cat_usersave');

     

     

     

  • 相关阅读:
    linux 查看父进程号
    gitlab
    诺基亚C6常识详解
    C#.net书籍列表
    表链接
    Limu:JavaScript的那些书(转载)
    Oracle 多行记录合并/连接/聚合字符串的几种方法
    关于有锁iPhone的常识(转载)
    not in与not exists性能比较
    多表连接查询
  • 原文地址:https://www.cnblogs.com/xingchong/p/13810667.html
Copyright © 2011-2022 走看看