当前所在位置:珠峰网资料 >> 计算机 >> Oracle认证 >> 正文
Oracle表、索引修改表空间语句
发布时间:2010/10/15 15:13:26 来源:城市学习网 编辑:ziteng
  表做空间迁移时,使用如下语句:
  例1:alter table tb_name move tablespace tbs_name;
  索引表空间做迁移,使用如下语句:
  例2:alter index index_name rebuild tablespace tbs_name;
  对于含有lob字段的表,在建立时,oracle会自动为lob字段建立两个单独的segment,一个用来存放数据,另一个用来存放索引,并且它们都会存储在对应表指定的表空间中,而例1:只能移动非lob字段以外的数据,所以在对含有lob字段的表进行空间迁移,需要使用如下语句:
  例3:alter table tb_name move tablespace tbs_name lob (col_lob1,col_lob2) store as(tablesapce tbs_name);
  项目实例:
  表空间迁移
  select 'alter table' ||table_name|| 'move tablespace tbs_name;' table_name from dba_tables where owner='%***%' and table_name like '%***%'
  带lob字段
  select 'alter table' ||table_name|| 'move lob('||index_name||') store as (tablespace tbs_name);' from dba_indexes where owner='%***%' and index_name like '%***%'
  索引表空间
  select 'alter index' ||index_name|| 'rebuild tablespace tbs_name;' index_name from dba_indexes where owner='%***%' and table_name like '%***%'
  以上在oracle 的SQL*Plus Worksheet中运行,将得出的运行结果再运行一次即可。
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved