Oracle数据库中表空间(数据文件)的扩展方法

来源:互联网 发布:专业篮球教学软件 编辑:程序博客网 时间:2024/05/18 03:07

第一步:首先要确定表空间名字及数据文件的位置:

    select tablespace_name, file_id, file_name,

    round(bytes/(1024*1024),0) total_space

    from dba_data_files

    order by tablespace_name;


第二步:选择一种适合的扩展表空间的方式,一般有有三种方式可以扩展表空间:

     方法一:数据文件的resize来扩:

    SQL> alter database datafile '/oracle/oradata/orcl/user_test02.dbf' resize 20m;

    方法二:添加数据文件的方式来扩:

    SQL> alter tablespace USER_TEST add datafile '/oracle/oradata/orcl/user_test02.dbf' size 10M;

    第三种方法:设置数据文件自动扩展:

    alter tablespace USER_TEST add datafile '/oracle/oradata/orcl/user_test02.dbf' size 10M; 


最后查看表空间使用情况:

    查看表空间大小:

select tablespace_name,sum(bytes)/1024/1024 from dba_data_files group by tablespace_name;

    查看表空间已使用大小:

select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by tablespace_name;

0 0