mysql和oracle查詢表占用空間

2021-09-23 07:53:57 字數 1763 閱讀 4953

mysql

需要先進入information_schema

select 

table_schema as '資料庫',

table_name as '表名',

table_rows as '記錄數',

truncate(data_length/1024/1024, 2) as '資料容量(mb)',

truncate(index_length/1024/1024, 2) as '索引容量(mb)'

from information_schema.tables

where table_schema='ln_hbpz'

order by data_length desc, index_length desc;

select table_name , (data_length/1024/1024) as data_mb , (index_length/1024/1024)   

as index_mb, ((data_length+index_length)/1024/1024) as all_mb, table_rows

from information_schema.tables where table_schema = 'test' order by all_mb desc;

table_name --表名

data_mb --資料容量

index_mb --索引容量

all_mb --總容量

table_rows --條數

information_schema.tables --在這個庫information_schema中的tables中查詢

test --庫名

oracle

select upper(f.tablespace_name) "表空間名",

d.tot_grootte_mb "表空間大小(m)",

d.tot_grootte_mb - f.total_bytes "已使用空間(m)",

to_char(round((d.tot_grootte_mb - f.total_bytes) / d.tot_grootte_mb * 100,

2),'990.99') "使用比",

f.total_bytes "空閒空間(m)",

f.max_bytes "最大塊(m)"

from (select tablespace_name,

round(sum(bytes) / (1024 * 1024), 2) total_bytes,

round(max(bytes) / (1024 * 1024), 2) max_bytes

from sys.dba_free_space 

group by tablespace_name) f,

(select dd.tablespace_name,

round(sum(dd.bytes) / (1024 * 1024), 2) tot_grootte_mb

from sys.dba_data_files dd

group by dd.tablespace_name) d

where d.tablespace_name = f.tablespace_name

/* and f.tablespace_name = 'd_test_01'*/

order by 4 desc;

MySQL 和Oracle 查詢區別

有以下兩種寫法 一 select a.id,a.url,b.campaign,b.groups,b.keywords where a.id b.ad id and a.name bat 20120418142217 二 在oracle 中兩種查詢幾乎沒有區別,但在mysql 中有10倍以上的差異 在...

mysql和Oracle 備份表

1.sql server中,如果目標表存在 insertinto目標表select from原表 2.sql server中,如果目標表不存在 select into目標表from原表 mysql中不支援這種語法,變通一下,自己測了可用 create table table2 select from...

oracle 查詢所有表和字段

select from all tab comments 查詢所有使用者的表,檢視等 select from user tab comments 查詢本使用者的表,檢視等 select from all col comments 查詢所有使用者的表的列名和注釋.select from user co...