作者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)
1F:推 fooker:请问语法里一定得把index放在table里吗,直接在tablespace 08/27 16:39
2F:推 fooker:建index可否?如何得知是否复合型index?如何查column?thanks 08/27 16:46
3F:→ 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)
4F:推 fooker:感谢,我index有建立了是不是放错TABLE,所以无效?问题依旧 08/28 09:59
5F:→ kobedisel:直接查dba_indexes owner就等於你的username去查状态 08/28 13:59