• 计算mysql 数据库 表大小 服务器传输 小写表明转成大写


    //数据库表存储大小

    select table_schema,table_name,table_rows,concat(round(data_length/1024/1024/1024,2),'GB') length from tables where table_schema='ERP' order by table_rows desc;

    //一台服务器传输到另一台服务器 路径写法

    scp /home/table_t_user.sql  root@115.29.249.149:/home

    //数据表存储大小

    参考地址:http://www.2cto.com/database/201403/284682.html

    有时候需要查询MySQL数据库中各个表大小,该如何操作呢?

    MySQL中有一个名为 information_schema 的数据库,在该库中有一个 TABLES 表,这个表主要字段分别是:

    TABLE_SCHEMA : 数据库名
    TABLE_NAME:表名
    ENGINE:所使用的存储引擎
    TABLES_ROWS:记录数
    DATA_LENGTH:数据大小
    INDEX_LENGTH:索引大小

    其他字段请参考MySQL的手册。

    use information_schema;
    SELECT 
       TABLE_NAME,
    	(DATA_LENGTH/1024/1024) as DataM ,
    	(INDEX_LENGTH/1024/1024) as IndexM, 
    	((DATA_LENGTH+INDEX_LENGTH)/1024/1024) as AllM,
    	TABLE_ROWS
    FROM
        TABLES
    WHERE
        TABLE_SCHEMA = 'db_ip';


    /////////////////////////////////////////////////////////////////////
    //oracle sql小写表明转成大写
    begin  
       for c in (select table_name tn from user_tables where table_name <> upper(table_name)) loop  
           begin  
              execute immediate 'alter table "'||c.tn||'" rename to '||c.tn;  
           exception  
              when others then  
                 dbms_output.put_line(c.tn||'已存在');  
           end;  
       end loop;   
    end;
    ///////////////////////////////////////////////////////////////////

    ////////////////////////////////////////////////////////////////////

    //oracle sql 字段改成大写

    begin
      DBMS_OUTPUT.ENABLE (buffer_size=>null) ;

      for t in (select table_name tn from user_tables) loop

          begin

             for c in (select column_name cn from user_tab_columns where table_name=t.tn) loop

                 begin

                    execute immediate 'alter table "'||t.tn||'" rename column "'||c.cn||'" to '||c.cn;

                 exception

                    when others then

                       dbms_output.put_line(t.tn||'.'||c.cn||'已经存在');

                 end;

             end loop;

          end;

      end loop;

    end;


    ////////////////////////////////////////////////////////////////////




  • 相关阅读:
    C语言 选择排序算法原理和实现 从数组中 找出最小的元素然后交换位置
    C语言十六进制转换成十进制:要从右到左用二进制的每个数去乘以16的相应次方
    pycharm的注册码,所有版本
    无法链接glew的解决办法-编译开源库出现: error LNK2001: 无法解析的外部符号
    删除文件是遇到“拒绝访问”的解决方法
    基类的析构函数写成virtual虚析构函数
    C++语言定义的标准转换
    VC中C++数值范围的确定
    SCI投稿过程总结、投稿状态解析、拒稿后对策及接受后期相关问答
    STL其他--<tuple>用法【C11】
  • 原文地址:https://www.cnblogs.com/gzyx1988/p/5662988.html
Copyright © 2020-2023  润新知