oracle表空间相关语句

1、查看表空间文件

        select * from dba_data_files;

2、查看用户的默认表空间

        select username,default_tablespace from dba_users;

3、查看表空间大小

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;

4、查看表空间使用情况

SELECT a.tablespace_name "表空间名",
       total / (1024 * 1024 * 1024) "表空间大小(G)",
       free / (1024 * 1024 * 1024) "表空间剩余大小(G)",
       (total - free) / (1024 * 1024 * 1024) "表空间使用大小(G)",
       round((total - free) / total, 4) * 100 "使用率 %"
  FROM (SELECT tablespace_name, SUM(bytes) free
          FROM dba_free_space
         GROUP BY tablespace_name) a,
       (SELECT tablespace_name, SUM(bytes) total
          FROM dba_data_files
         GROUP BY tablespace_name) b
 WHERE a.tablespace_name = b.tablespace_name;

5、创建表空间

create tablespace TSI_HSPS datafile :\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TSI_HSPS_1.DAT' size 1g;

create tablespace dmusertbs
datafile 'i:\oracle\oradata\dmusertbs01.dbf' size 50M,
         'i:\oracle\oradata\dmusertbs02.dbf' size 50M,
         'i:\oracle\oradata\dmusertbs03.dbf' size 50M

    注意:Oracle 数据文件的扩展名没有任何限制,你可以使用任意扩展名,或者不用扩展名。

5. 扩展表空间

alter tablespace tablespace_name
            add datafile '表空间文件名' size 500M
            autoextend on
            next 50M
            maxsize 2000M;
增加了一个500M的数据文件,并且可以自动扩展到2000M,每次扩展50M。
增加当前数据文件的大小

alter database datafile '表空间文件' resize 500M;

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

永字诀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值