oracle中怎么查看表的大小

oracle中怎么查看表的大小,第1张

可用如下语句查看:

select round(BYTES/1024/1024,2)||'M' from user_segments where segment_name='表名';

注意:表名需要用英文大写。

如要查询数据库中emp表的大小,用如下语句:

select round(BYTES/1024/1024,2)||'M' from user_segments where segment_name='EMP';

查询结果:

查询结果代表EMP表所占空间大小为006M。

select segment_name,segment_type,bytes/1024 from user_segments;

通关过segment,也可以查到你表的具体大小,上面精确到了字节单位,如果想变成M,则后面bytes/1024/1024即可。

首先,向你介绍一下information_schema。

information_schema这张数据表保存了MySQL服务器所有数据库的信息。如数据库名,数据库的表,表栏的数据类型与访问权限等。再简单点,这台MySQL服务器上,到底有哪些数据库、各个数据库有哪些表,每张表的字段类型是什么,各个数据库要什么权限才能访问,等等信息都保存在information_schema表里面。

所以,你需要查表信息应该去这个库查

sql语句是

select from information_schematables where table_schema='dbname';

希望采纳,祝您愉快!

--得到数据库中所有表的空间/记录情况

exec sp_MSForEachTable

@precommand=N'

create table ##(

id int identity,

表名 sysname,

字段数 int,

记录数 int,

保留空间 Nvarchar(10),

使用空间 varchar(10),

索引使用空间 varchar(10),

未用空间 varchar(10))',

@command1=N'insert ##(表名,记录数,保留空间,使用空间,索引使用空间,未用空间) exec sp_spaceused ''''

update ## set 字段数=(select count() from syscolumns where id=object_id(''''))

where id=scope_identity()', @postcommand=N'select from ## order by id drop table ##'

查询所有数据库占用磁盘空间大小的SQL语句:

复制代码

代码如下:

select

TABLE_SCHEMA,

concat(truncate(sum(data_length)/1024/1024,2),'

MB')

as

data_size,

concat(truncate(sum(index_length)/1024/1024,2),'MB')

as

index_size

from

information_schematables

group

by

TABLE_SCHEMA

order

by

data_length

desc;

查询单个库中所有表磁盘占用大小的SQL语句:

复制代码

代码如下:

select

TABLE_NAME,

concat(truncate(data_length/1024/1024,2),'

MB')

as

data_size,

concat(truncate(index_length/1024/1024,2),'

MB')

as

index_size

from

information_schematables

where

TABLE_SCHEMA

=

'TestDB'

group

by

TABLE_NAME

order

by

data_length

desc;

以上语句测试有效,注意替换以上的TestDB为数据库名

以上就是关于oracle中怎么查看表的大小全部的内容,包括:oracle中怎么查看表的大小、如何查看oracle 数据库中表的大小、如何用PHP查询一个数据库 有多少张表 多少条记录数 和大小等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9549425.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-29
下一篇2023-04-29

发表评论

登录后才能评论

评论列表(0条)

    保存