SQL> create index idx_test on test(id1)tablespace IDX nologging online parallel 4;
Index created.
SQL> alter index idx_test noparallel;
Index altered.
SQL> select degree from dba_indexes where index_name='IDX_TEST';
DEGREE
----------------------------------------
1
在一个24*7的应用上,需要把一个访问量很大的1000万以上数据级别的表的普通索引(a,b)修改成唯一约束(a,b,c)
create index idx_test on test(a,b,c) online;
alter table test add constraint cons_test unique (a,b,c) using index idx_test;
先移动表的表空间:
SQL> alter table test move tablespace LLC;
Table altered.
再移动索引的表空间:
SQL> alter index idx_test rebuild tablespace LLC;
Index altered.
查询索引(或者表)在数据文件上的分布:
SELECT DISTINCT (b.file_name), a.owner, a.segment_name
FROM dba_extents a, dba_data_files b
WHERE a.file_id = b.file_id
AND a.segment_name = 'IDX_LOTHISTORY_MODULEID'
AND a.owner = 'RPT'
重建索引,关注临时表空间的使用:
SELECT round((f.bytes_free + f.bytes_used) / 1024 / 1024, 2) "total MB",
round(((f.bytes_free + f.bytes_used) - nvl(p.bytes_used, 0)) / 1024 / 1024,
2) "Free MB",
d.file_name "Datafile name",
round(nvl(p.bytes_used, 0) / 1024 / 1024, 2) "Used MB",
round((f.bytes_free + f.bytes_used) / 1024, 2) "total KB",
round(((f.bytes_free + f.bytes_used) - nvl(p.bytes_used, 0)) / 1024,
2) "Free KB",
round(nvl(p.bytes_used, 0) / 1024, 2) "Used KB",
0 "Fragmentation Index"
FROM sys.v_$temp_space_header f,
dba_temp_files d,
sys.v_$temp_extent_pool p
WHERE f.tablespace_name(+) = d.tablespace_name
AND f.file_id(+) = d.file_id
AND p.file_id(+) = d.file_id
转载于:https://blog.51cto.com/7642644/1699084