转移表和索引所在的表空间



  如果你将创建表和索引创建在USERS表空间下了,(注:在USERS表空间中是合理的),那么在以后的维护中将会出现很多麻烦。

  如果是oltp系统无法删除重建,所以必须考虑在不影响使用的情况下做该项工作。

  客户系统:linux9+Oracle10g

  ◆1、知道命令:

  alter table table_name move tablespace tablespace_name;

  所以考虑这个方向:

select ''alter table '' || table_name || ''
move tablespace tablespace_name;''
from user_tables
 where tablespace_name = ''USERS''


  得到该连接用户下所有创建在USERS表空间下的表名。

  ◆2、执行所得到的语句,至此将表转移到新表空间中。

  ◆3、重建索引

  得到重建索引语句

SELECT ''alter index ''||index_name||''
rebuild tablespace tablespace_name storage(¡­¡­);''
FROM USER_INDEXES T where t.table_owner=''USER_NAME''
and t.tablespace_name=''USERS''


  ◆4、执行得到的语句,将索引转移到新表空间。

  注释:在此过程中全文索引的转移会出错,大家可以忽略不计

本文作者:


  如果你将创建表和索引创建在USERS表空间下了,(注:在USERS表空间中是合理的),那么在以后的维护中将会出现很多麻烦。

  如果是oltp系统无法删除重建,所以必须考虑在不影响使用的情况下做该项工作。

  客户系统:linux9+Oracle10g

  ◆1、知道命令:

  alter table table_name move tablespace tablespace_name;

  所以考虑这个方向:

select ''alter table '' || table_name || ''
move tablespace tablespace_name;''
from user_tables
 where tablespace_name = ''USERS''


  得到该连接用户下所有创建在USERS表空间下的表名。

  ◆2、执行所得到的语句,至此将表转移到新表空间中。

  ◆3、重建索引

  得到重建索引语句

SELECT ''alter index ''||index_name||''
rebuild tablespace tablespace_name storage(¡­¡­);''
FROM USER_INDEXES T where t.table_owner=''USER_NAME''
and t.tablespace_name=''USERS''


  ◆4、执行得到的语句,将索引转移到新表空间。

  注释:在此过程中全文索引的转移会出错,大家可以忽略不计

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3