zoukankan      html  css  js  c++  java
  • mysql常用; group by 高级

      1. 按照原历史表新增一个新表(空表):

      mysql> create table history_log_new ...;

          2. 给历史表重命名,并将新表重命名为历史表:

      mysql> RENAME TABLE history_log to history_log_20151217, history_log_new to history_log;

       mysqldump -uroot -p -h --databases --tables user --where='' > 导出数据

          3:查看binlog日志

      mysqlbinlog --start-datetime='2017-12-08 04:56:02' --stop-datetime='2017-12-08 04:56:10' --base64-output=decode-rows -v mysql-bin.000264

         4:高级group by使用 利用高级时间函数 对时间分组(created是创建的实时时间, 需要用date_format格式化到每日时间)

      SELECT count(*),date_format(created,"%y-%m-%d") as date FROM cn_send_phone_history group by date_format(created,"%yyyy-%m-%d");

         5:查看mysql存储

         USE information_schema;

       SELECT TABLE_SCHEMA, SUM(DATA_LENGTH)/1024 FROM TABLES GROUP BY TABLE_SCHEMA;

         6:批量truncate表

         SELECT CONCAT("TRUNCATE TABLE `", t.TABLE_NAME, '`;') FROM information_schema.`TABLES`  t  WHERE t.TABLE_NAME  LIKE "l3%";

  • 相关阅读:
    1836Alignment
    JS日期格式化
    excle自编公式方法
    excle的公式说明
    小技巧之一 string[]合并
    Nunit的使用小问题
    Ajax中上传文件的方式
    VSS也有BUG?
    SQL Server中将时间型的转为yyyyMMddhhmmss
    给已经存在的PDF文件加水印
  • 原文地址:https://www.cnblogs.com/a-flydog/p/6239987.html
Copyright © 2011-2022 走看看