
1、创建测试表,
create table test_index(id varchar2(20), v_date date)
2、将id字段,添加索引;
-- Create/Recreate indexes
create index idx_test_index_id on TEST_INDEX (id)
3、编写sql,查看系统视图,查找该索引是否存在;
select * from user_indexes t where index_name = upper('idx_test_index_id');
4、执行sql语句,并查看执行计划,可以发现索引已经起了作用;
可以用create index创建索引,如create index test_idx on tablename(col1,col2)系统优化时会自动选择使整个查询开销最小的查询计划。如你的sql 为select * from tablename where col1 = @col1 and col2 = @col2 时一般都会用到索引。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)