更改oracle表空间路径指向

     总共分为四步:

1、查询表空间使用情况及文件存放路径:

select
dbf.tablespace_name,
dbf.file_name "文件路径",
dbf.totalspace "总量(M)",
dbf.totalblocks as 总块数,
dfs.freespace "剩余总量(M)",
dfs.freeblocks "剩余块数",
(dbf.totalspace-dfs.freespace) "已用总量(M)",
(dfs.freespace / dbf.totalspace) * 100 "空闲比例(%)",
dbf.AUTOEXTENSIBLE "是否自动增长"
from
(select t.tablespace_name,t.file_name,t.AUTOEXTENSIBLE,sum(t.bytes) / 1024 / 1024 totalspace,sum(t.blocks) totalblocks
from dba_data_files t group by t.tablespace_name,t.file_name,t.AUTOEXTENSIBLE) dbf,
(select tt.tablespace_name,sum(tt.bytes) / 1024 / 1024 freespace,sum(tt.blocks) freeblocks
from dba_free_space tt group by tt.tablespace_name) dfs
where trim(dbf.tablespace_name) = trim(dfs.tablespace_name);

2、offline表空间

alter tablespace tablespace_name offline;

3、利用cp或者mv命令移动表空间文件到新的目录,并将移动后的文件权限设为最大777;

4、online表空间

alter tablespace tablespace_name online;

修改完毕!

      修改过程中不需要重启服务器、不需要重启tomcat、不需要重启数据库服务,不过在offline期间,该时间段产生的数据可能会有丢失,所以谨慎!

你可能感兴趣的:(服务器)