把表和索引移动到另外的表空间
2011-05-07 10:36
225 查看
查看表和索引所在的表空间所用视图:dba_segments,还可能会用dba_lobs;
1)移动的表:
alter table tb_name move tablespace tbs_name;
2)移动带clob,blob的字段:
alter table tb_name move tablespace tbs_name lob (col_lob1,col_lob2) store as(tablespace lobs_tbs_name);
3)移动索引
alter index idx_name rebuild tablespace idx_tbs_name;
查看表空间里的内容
SQL> SELECT t.owner, t.segment_name, t.segment_type
2 FROM dba_segments t
3 WHERE t.tablespace_name = 'LOBTPS_NAME';
查看LOB表空间里的内容
SQL> SELECT t.owner, t.table_name, t.column_name, t.segment_name, t.index_name
2 FROM dba_lobs t
3 WHERE t.tablespace_name = 'LOBTPS_NAME';
新建一个临时表空间
CREATE TABLESPACE lobtbs1 DATAFILE '/data/directory/LOBTPS_NAME_MOVEBK.dbf' SIZE 200M;
alter user your_user_name quota unlimited on LOBTPS_NAME_MOVEBK;
批量移动表
SQL> SELECT 'alter table ' || t.owner || '.' || t.segment_name ||
2 ' move tablespace LOBTPS_NAME;'
3 FROM dba_segments t
4 WHERE t.tablespace_name = 'LOBTPS_NAME_MOVEBK'
5 AND t.segment_type = 'TABLE';
批量移动索引
SELECT 'alter index ' || index_name ||
' rebuild tablespace new_idx_tbs;'
FROM user_indexes
WHERE tablespace_name = 'OLD_IDX_TBS';
批量移动lob字段
SQL> SELECT 'alter table ' || t.owner || '.' || t.table_name ||
2 ' move tablespace LOBTPS_NAME lob (' || t.column_name ||
3 ') store as(tablespace LOBTPS_NAME_MOVEBK);' v_sql
4 FROM dba_lobs t
5 WHERE t.tablespace_name = 'LOBTPS_NAME';
SQL> alter database datafile 8 resize 100 M;
Database altered
1)移动的表:
alter table tb_name move tablespace tbs_name;
2)移动带clob,blob的字段:
alter table tb_name move tablespace tbs_name lob (col_lob1,col_lob2) store as(tablespace lobs_tbs_name);
3)移动索引
alter index idx_name rebuild tablespace idx_tbs_name;
查看表空间里的内容
SQL> SELECT t.owner, t.segment_name, t.segment_type
2 FROM dba_segments t
3 WHERE t.tablespace_name = 'LOBTPS_NAME';
查看LOB表空间里的内容
SQL> SELECT t.owner, t.table_name, t.column_name, t.segment_name, t.index_name
2 FROM dba_lobs t
3 WHERE t.tablespace_name = 'LOBTPS_NAME';
新建一个临时表空间
CREATE TABLESPACE lobtbs1 DATAFILE '/data/directory/LOBTPS_NAME_MOVEBK.dbf' SIZE 200M;
alter user your_user_name quota unlimited on LOBTPS_NAME_MOVEBK;
批量移动表
SQL> SELECT 'alter table ' || t.owner || '.' || t.segment_name ||
2 ' move tablespace LOBTPS_NAME;'
3 FROM dba_segments t
4 WHERE t.tablespace_name = 'LOBTPS_NAME_MOVEBK'
5 AND t.segment_type = 'TABLE';
批量移动索引
SELECT 'alter index ' || index_name ||
' rebuild tablespace new_idx_tbs;'
FROM user_indexes
WHERE tablespace_name = 'OLD_IDX_TBS';
批量移动lob字段
SQL> SELECT 'alter table ' || t.owner || '.' || t.table_name ||
2 ' move tablespace LOBTPS_NAME lob (' || t.column_name ||
3 ') store as(tablespace LOBTPS_NAME_MOVEBK);' v_sql
4 FROM dba_lobs t
5 WHERE t.tablespace_name = 'LOBTPS_NAME';
SQL> alter database datafile 8 resize 100 M;
Database altered
相关文章推荐
- 如何把索引移动到另外的表空间
- Oracle表和索引移动表空间
- 如何移动一个带有lob字段的表到另外一个表空间
- 移动表到新表空间后重建索引
- 将索引移动到别的表空间
- 移动一个带有lob字段的表到另外一个表空间
- 将索引移动到别的表空间
- 移动分区表和分区索引的表空间
- 移动lob类型索引到指定表空间
- 【转】移动oracle LOB索引到其他表空间
- 移动分区表和分区索引的表空间
- 移动表到另外一个表空间
- 移动 表、表分区、LOB字段、索引、分区索引 到另一表空间!
- 移动分区表和分区索引的表空间
- 将索引移动到别的表空间
- 如何移动LOB索引到其他表空间
- mongodb地理空间索引原理阅读摘要
- PostgreSQL 查看数据库,索引,表,表空间大小
- 批量更改表和索引存储的表空间
- 查看Oracle当前用户下的信息(用户,表视图,索引,表空间,同义词,存储过程函数,约束条件)自_baidu