drop table test1;
create table test1(c1 varchar2(100) PRIMARY key,c2 varchar2(100));
create index idx_test1_c1 on test1(c1);
insert into test1 select guid(),guid() from dual connect by level < 10000;commit;
drop table test2;
create table test2(c1 varchar2(20));
insert into test2 select c1 from test1;
insert into test2 select c1 from test1 index idx_test1_c1;
首先是第一段话的意思: INSERT 语句有两种形式,一种值插入形式,即常见的 insert into table1 values (1); 另一种查询插入形式,即 insert into table1 select * from table2; 把从table2查询到的数据插入到表table1。
然后语法中指定index <索引名> 的作用可以指定查询语句是通过哪条索引进行查询的。举个例子如下:
drop table test1;
create table test1(c1 varchar2(100) PRIMARY key,c2 varchar2(100));
create index idx_test1_c1 on test1(c1);
insert into test1 select guid(),guid() from dual connect by level < 10000;commit;
drop table test2;
create table test2(c1 varchar2(20));
insert into test2 select c1 from test1;
insert into test2 select c1 from test1 index idx_test1_c1;
通过F9查看两个insert语句的执行计划,可以看到走了不同的索引。第一条走了主键索引,第二条走了idx_test1_c1索引。

