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
在一個(gè)24*7的應(yīng)用上,需要把一個(gè)訪問(wèn)量很大的1000萬(wàn)以上數(shù)據(jù)級(jí)別的表的普通索引(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;
先移動(dòng)表的表空間: SQL> alter table test move tablespace LLC; Table altered. 再移動(dòng)索引的表空間: SQL> alter index idx_test rebuild tablespace LLC; Index altered.
查詢索引(或者表)在數(shù)據(jù)文件上的分布: 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'
重建索引,關(guān)注臨時(shí)表空間的使用:
創(chuàng)新互聯(lián)建站是一家專業(yè)提供五臺(tái)企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站制作、做網(wǎng)站、H5建站、小程序制作等業(yè)務(wù)。10年已為五臺(tái)眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)絡(luò)公司優(yōu)惠進(jìn)行中。
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