查看各表空间的使用情况

select a.tablespace_name,a.bytes/1024/1024 "Sum MB",(a.bytes-b.bytes)/1024/1024 "used MB",b.bytes/1024/1024 "free MB",
round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"
from
(select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,
(select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b
where a.tablespace_name=b.tablespace_name
order by ((a.bytes-b.bytes)/a.bytes) desc
select * from dba_data_files
order by tablespace_name, file_name; select tablespace_name,dba_tablespaces.* from dba_tablespaces

表真实占用的空间

select OWNER, t.segment_name, t.segment_type,
sum(t.bytes / 1024 / 1024/1024) USED_G
from dba_segments t
where t.owner LIKE '%ODS%'
AND SEGMENT_NAME NOT LIKE 'BIN$%'
group by OWNER, t.segment_name, t.segment_type
order by OWNER, USED_G desc;
--1、查看表空间的名称及大小
select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
--2、查看表空间物理文件的名称及大小
select tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name;
alter tablespace {表空间名字} add datafile '物理数据文件路径' SIZE 『初始大小M』 AUTOEXTEND ON NEXT 『自动扩展大小M』

alter tablespace SDK_TB add datafile '/oradata/ORA11G/sdk_tb2.dbf' size 1000m autoextend on next 200m

如果datafile加错到表空间,执行删除

Alter tablespace SDK_TB drop datafile '/oradata/ORA11G/a_tb04.dbf';
或者
alter database datafile '/oradata/ORA11G/a_tb04.dbf' offline drop;

查看临时表空间

select * from dba_temp_files
where tablespace_name = 'DEV_TEMP2'
order by tablespace_name, file_name;

添加临时表空间文件

alter tablespace  DEV_TEMP2 add tempfile '/data/phonedb/datafile/dev_temp3.dbf' size 1000m autoextend on next 200m

修改用户默认表空间

alter user user_name default tablespace dev_tb;
alter user user_name temporary tablespace dev_temp;

查看数据文件是否有数据:

只需查看数据文件中是否包含extent段。如果有extent(索引段,数据段)段,则说明数据文件中有数据。
使用dba_extents视图和dba_data_files视图进行连接查询。

select t.file_name,t1.owner,t1.segment_name,t1.segment_type,t1.tablespace_name from dba_data_files t,dba_extents t1 where t.file_id=t1.file_id and file_name='你要查询的数据文件路径';

oracle查看表空间和物理文件大小的更多相关文章

  1. Oracle查看表空间及修改数据文件大小

    Oracle查看表空间及修改数据文件大小 第一步:查看所有表空间及表空间大小: select tablespace_name ,sum(bytes) / 1024 / 1024 as MB from ...

  2. oracle查看表空间的大小及使用情况sql语句

    --------------------------tablespace------------------------------------------------ 1.//查看表空间的名称及大小 ...

  3. Oracle 查看表空间的大小及使用情况sql语句

    --1.查看表空间的名称及大小 )), ) ts_size FROM dba_tablespaces t, dba_data_files d WHERE t.tablespace_name = d.t ...

  4. Oracle 查看表空间大小及其扩展

    在ORACLE数据库中,所有数据从逻辑结构上看都是存放在表空间当中,当然表空间下还有段.区.块等逻辑结构.从物理结构上看是放在数据文件中.一个表空间可由多个数据文件组成.系统中默认创建的几个表空间:S ...

  5. oracle 查看表空间以及剩余量

    --1.查看表空间的名称及大小 SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size FROM dba_tabl ...

  6. oracle 查看表空间以及日志文件等系统文件

    --1.查看表空间的名称及大小 )), ) ts_size FROM dba_tablespaces t, dba_data_files d WHERE t.tablespace_name = d.t ...

  7. oracle查看表空间及大小

    --1.查看表空间的名称及大小 SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size FROM dba_tabl ...

  8. ORACLE查看表空间对象

    ORACLE如何查看表空间存储了那些数据库对象呢?可以使用下面脚本简单的查询表空间存储了那些对象: SELECT TABLESPACE_NAME       AS TABLESPACE_NAME    ...

  9. Oracle查看表空间使用情况

     查看表空间使用情况 select upper(f.tablespace_name) "表空间名",        d.tot_grootte_mb "表空间大小(m ...

随机推荐

  1. python脚本3_输入若干个整数打印出最大值

    #输入若干个整数,打印出最大值 # m = int(input('Input first number >>>')) while True: c = input('Input a n ...

  2. Codeforces Round #451 (Div. 2)

    水题场.... 结果因为D题看错题意,B题手贱写残了...现场只出了A,C,E A:水题.. #include<bits/stdc++.h> #define fi first #defin ...

  3. 牛客比赛-状压dp

    链接:https://www.nowcoder.com/acm/contest/74/F来源:牛客网 德玛西亚是一个实力雄厚.奉公守法的国家,有着功勋卓著的光荣军史. 这里非常重视正义.荣耀.职责的意 ...

  4. C# 为什么用接口实例化一个实现该接口的类?

    这是多态的体现. 首先接口不能实例化的. 实现接口的类 实例 = new 实现接口的类()// 这样用不好吗? //这样已经不是好不好的问题了,这样的话,要接口有什么用?//用接口就是让实例和实现类的 ...

  5. SpringMVC札集(01)——SpringMVC入门完整详细示例(上)

    自定义View系列教程00–推翻自己和过往,重学自定义View 自定义View系列教程01–常用工具介绍 自定义View系列教程02–onMeasure源码详尽分析 自定义View系列教程03–onL ...

  6. Electron 使用 Webpack2 预编译 Electron 和 Browser targets

    Electron 使用 Webpack2 预编译 Electron 和 Browser targets 前一篇文章说了说怎样使用 Webpack2 预编译 Electron 应用,但是有时候我们希望使 ...

  7. Go语言的序列化与反序列化(gob)

    encoding/gob包实现了高效的序列化,特别是数据结构较复杂的,结构体.数组和切片都被支持. 实现代码如下://定义一个结构体type Student struct { Name string ...

  8. Centos 6.3 Realtek Audio Driver Compile

    /**************************************************************************** * Centos 6.3 Realtek A ...

  9. 机器学习(八)—Apriori算法

    摘要:本文对Apriori算法进行了简单介绍,并通过Python进行实现,进而结合UCI数据库中的肋形蘑菇数据集对算法进行验证. “啤酒与尿布”的例子相信很多人都听说过吧,故事是这样的:在一家超市中, ...

  10. Apache中 RewriteCond 规则参数介绍 转

    摘要: RewriteCond指令定义了规则生效的条件,即在一个RewriteRule指令之前可以有一个或多个RewriteCond指令.条件之后的重写规则仅在当前URI与Pattern匹配并且满足此 ...