作者fantasyj (如夢似幻)
看板Database
標題Re: [SQL ] 請ORACLE高手解答,謝謝
時間Fri Aug 27 14:14:23 2010
語法:
create unique index <index name> on <table name> (columns name)
tablespace <tablespace name>;
create index <index name> on <table name> (columns name)
tablespace <tablespace name>;
例如:
create unique index AOM.AOM_EO_DELAYS_U1 on AOM.AOM_EO_DELAYS (EO_DELAY_ID)
tablespace AOMX
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 40K
next 40K
minextents 1
maxextents 505
pctincrease 0
);
ps:上面舉例的額外的設定參數,沒加也沒關係,會自動依該db的預設值...
若是複合型index,只要在columns name內用一起輸入即可
create index AOM.AOM_EO_DELAYS_U1 on AOM.AOM_EO_DELAYS (EO_DELAY_ID, MST_ID)
tablespace AOMX;
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 202.3.165.131
※ 編輯: fantasyj 來自: 202.3.165.131 (08/27 14:18)
推 fooker:請問語法裏一定得把index放在table裏嗎,直接在tablespace 08/27 16:39
推 fooker:建index可否?如何得知是否複合型index?如何查column?thanks 08/27 16:46
→ fantasyj:嗯嗯 08/27 20:27
index當然是跟著table阿......只是可以存放在跟與該table不同的tablespace
tablespace算是個存放table & index的區塊,所以像我公司是使用oracle DB &
oralce ERP,oracle自家東西的規劃就是1個模組下,1個tableapace放table,然後
1個tablespace放index,方便維持管理(但是我記得好像是最新版12g已經改成1模組6個
tablespace,改善CBO的性能)
orz...複合型index就是2個以上的欄位(包含2個),建立"一個"index,並不是一個欄位就
建立一個index.....根據實際需求(SQL OR PL/SQL)來建立,更簡單說就是為了改善速度
而已.....
※ 編輯: fantasyj 來自: 59.117.183.250 (08/27 20:42)
推 fooker:感謝,我index有建立了是不是放錯TABLE,所以無效?問題依舊 08/28 09:59
→ kobedisel:直接查dba_indexes owner就等於你的username去查狀態 08/28 13:59