小编use*_*874的帖子

Oracle:单个多列索引或两个单列索引

我有桌子

create table1(
  column1 number(10,
  column2 number(10),
  column3 number(10)
);
Run Code Online (Sandbox Code Playgroud)

column1是主键 column2,column3是外键

我在2列上创建了唯一约束

alter table table1 
        add constraint table1_contr1 unique(column1,column2) 
      using index tablespace tbs1;
Run Code Online (Sandbox Code Playgroud)

当我在两个列上创建索引时

create index table1_idx1 on table1(column1,coulmn2);

ERROR at line 1:
ORA-01408: such column list already indexed
Run Code Online (Sandbox Code Playgroud)

因此Oracle在创建唯一约束时已经创建了索引.但如果我单独创建索引,它就会接受这些索引

create index table1_idx1 on table1(column1);
create index table2_idx2 on table2(column2);
Run Code Online (Sandbox Code Playgroud)

现在我的问题是,在对两列都有唯一约束后,我还需要担心在每列上创建索引吗?在访问对象时,每列上没有索引会对性能产生影响吗?

这是在oracle 11R2上.

sql indexing performance oracle11g

7
推荐指数
1
解决办法
6242
查看次数

添加具有默认值的列

我有一张桌子A(3列),大约有1000万条记录.我想在该表中再添加一列,并且我希望将默认值设置为1.是否会影响生产数据库性能如果添加默认值为1的列或其他内容.什么是最好的方法来避免对DB的任何性能影响?你的想法非常感谢!!

oracle oracle11g

5
推荐指数
1
解决办法
1530
查看次数

标签 统计

oracle11g ×2

indexing ×1

oracle ×1

performance ×1

sql ×1