zoukankan      html  css  js  c++  java
  • mysql常用sql语句

    1.清空用户下的所有表里面的数据

    select concat('truncate table ',table_name,';') from information_schema.TABLES where table_schema='test_cp';

    2.统计某个库下面的数据总量和表数目和总条目数

    SELECT count(*) TABLES, concat(round(sum(DATA_LENGTH/1024/1024),2),'M'),table_schema ,sum(table_rows)FROM information_schema.TABLES  t  where t.TABLE_SCHEMA='XX';

    3.查询每张表的条目数

     SELECT  table_name,table_rows,concat(round(DATA_LENGTH/1024/1024,2),'M') FROM information_schema.TABLES  t  where t.TABLE_SCHEMA='dwjy';

    4.语句拼接

    select CONCAT("insert into tt(uname,tname,records,spaces,systemName) select `用户名` ,`表名`,`记录数`,`占用空间(M)` ,"",t.TABLE_NAME,"" from `",t.TABLE_NAME,"`;") from tables t where t.TABLE_SCHEMA='dashuju';

    select CONCAT("select count(1),"",t.TABLE_NAME,"" from `",t.TABLE_NAME,"` union all") from `TABLES` t where t.table_schema='yu';

    select CONCAT("insert into tt(tname,records,systemName) select `表名称(英文)`,`记录数`,`系统名称`, from `",t.TABLE_NAME,"`;") from tables t where t.TABLE_SCHEMA='yu';

  • 相关阅读:
    第一周作业
    第一周作业
    C语言I博客作业07
    C语言I博客作业06
    C语言I博客作业03
    C语言I博客作业04
    c语言|博客作业02
    字段的约束验证
    [转]AS IS ? ??运算符
    BindingManagerBase 跟踪不一致
  • 原文地址:https://www.cnblogs.com/jycjy/p/9911114.html
Copyright © 2011-2022 走看看