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

时间:2023-03-10 06:26:19
计算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;

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