在表空间之间移动数据对象
一、基础脚本在Oracle数据库的表空间之间移动对象会涉及多种类型的数据对象
移动表:
- alter table t_a move tablespace tbs_a;
移动索引:
- alter index i_a rebuild tablespace tbs_a;
移动LOBSEGMENT:
- alter table t_a move lob(colume_a) store as (tablespace tbs_a);
根据实际检验LOBINDEX会随着相应的LOBSEGMENT自动移动
移动表的同时移动LOBSEGMENT:
- alter table t_a move tablespace tbs_a lob(colume_a) store as (tablespace tbs_a);
如果表中有字段为LONG类型的,那么该表不能按照上面的方法移动,只能使用EXP/IMP来移动了
二、批量生成移动脚本如果有大量的对象需要移动,一行一行写脚本就很不现实,可以使用下面的脚本来生成移动的脚本--生成LOBSEGMENT的移动语句,目的是把用户USR_A的LOBSEGMENT对象从表空间TBS_OLD移动到TBS_NEW,所生成的语句执行后,相应的LOBINDEX对象也会跟着移动到TBS_NEW
- select "alter table " || owner || "." || table_name || " move LOB(" || column_name || ") store as (tablespace TBS_NEW);" from dba_lobs where owner = "USR_A" and tablespace_name="TBS_OLD";
--如要把LOB段所在的表也随同LOB段移动到新的表空间,可使用以下语句来生成脚本
- select "alter table " || owner || "." || table_name || " move tablespace TBS_NEW LOB(" || column_name || ") store as (tablespace TBS_NEW);" from dba_lobs where owner = "USR_A" and tablespace_name="TBS_OLD";
--生成移动USR_A的表和索引的脚本,排序是为了移动表的脚本在前,移动索引的脚本在后,按序执行即可;否则先移索引后移表会导致索引失效
- select "alter " || segment_type || " USR_A." || segment_name || " " || decode(segment_type,"TABLE","move","INDEX","rebuild") || " " || "tablespace TBS_NEW;" from dba_segments where owner = "USR_A" and tablespace_name="TBS_OLD" and segment_type in ("TABLE","INDEX") order by segment_type desc;
--可以用以下语句检查dba_indexes数据字典表中的失效的索引信息
- select * from dba_indexes where status = "UNUSABLE";
三、一些可能会用到的查询语句另外还有一些可能会用到的查询表空间中数据对象信息的语句--统计用户USR_A的数据对象数
- select count(*) from dba_segments where owner="USR_A";
--查看用户USR_A的数据对象所分布的表空间名
- select distinct tablespace_name from dba_segments where owner="USR_A";
--查看用户USR_A的LOB段和LOB索引对象
- select * from dba_segments where owner="USR_A" and segment_type in ("LOBSEGMENT","LOBINDEX");
--分表空间、段类型统计用户USR_A的数据对象数
- select tablespace_name,segment_type,count(*) from dba_segments where owner="USR_A";
- group by tablespace_name,segment_type;
- order by tablespace_name,segment_type;
Hibernate各种主键生成策略与配置详解hibernate调用Oracle存储过程相关资讯 Oracle数据库 Oracle入门教程 oracle数据库教程
- Oracle数据库全球化 (03月01日)
- Oracle数据库日期过滤方法性能比较 (02/02/2015 13:20:26)
- Oracle数据库安装中端口被占用问题 (10/29/2014 07:42:24)
| - 在CentOS 6.6上搭建C++运行环境并 (10/10/2015 19:44:40)
- Oracle数据库无法使用localhost和 (11/14/2014 16:39:10)
- 使用SQLT来构建Oracle测试用例 (08/28/2014 06:17:41)
|
本文评论 查看全部评论 (0)