【Oracle】查看oracle表空间大小及增加表空间的几种方法

在oracle中表空间是必不可少的。但是怎么查看表空间呢


简单的查看方式是:

SQL> select tablespace_name from dba_tablespaces;


想要查看表空间对应的物理文件是什么需要这样查看:

SQL> select file_name ,tablespace_name,bytes/1024/1024 "bytes MB" ,max_bytes/1024/1024 " max_bytes MB "from dba_data_files where tablespace_name='表空间名';


想要查看数据库表空间的使用情况药这样查看:

SQL> set pages 1000;
SQL> set lines 100;
SQL> col tablespace_name for a20;
SQL> col total_sizes for a10;
SQL> col free_sizes for a10;
SQL> col max_continue_sizes for a20;
SQL> select (tablespace_name) "tablespace_name",   
           sum(total_size) || 'M' as "total_sizes",   
           sum(total_free) || 'M' as "free_sizes",   
           sum(max_continue) || 'M' as "max_continue_sizes",   
           round(sum(total_free) / sum(total_size) * 100) as "free(%)"  
       from ((select tablespace_name,   
                    (0) total_size,   
                    round(sum(bytes) / 1024 / 1024, 2) total_free,   
                    round(max(bytes) / 1024 / 1024, 2) max_continue   
                  from dba_free_space   
                  group by tablespace_name) union all  
                  (select tablespace_name, round(sum(bytes) / 1024 / 1024, 2), 0, 0   
                  from dba_data_files   
                  group by tablespace_name))   
      group by tablespace_name   
      order by 5 asc;


想要增加表空间有两种方式:

一、将原表空间的文件resize更大(只有从小到大,尽量不要从大到小)

二、增加新的数据文件datafile

具体操作:

一、原表空间数据文件增大

SQL> alter database datafile '/u01/app/oracle/oradata/xxxx/xxx.dbf' resize 10g;

二、增加datafile

SQL> alter tablespace 表空间名 add datafile'/u01/app/oracle/oradata/xxxx/xxxx02.dbf' size 10g;

其实还有一种是表空间自动增长


SQL> alter database datafile '/u01/app/oracle/oradata/xxx/xxxx.dbf' autoextend on next 1g maxsize 20g;
















评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值