重庆协创Oracle培训中心与您分享Oracle数据库视图和索引是什么。
视图
以经过定制的方式显示来自一个或多个表的数据。
创建视图:
create or replace view user_tbl_view(vid,vname,vage) as select id,user_name,age from user_tbl [with check option]|[with read only];
创建带有错误的视图:
create force view user_tbl_force_view as
select * from user_table;——此时user_table可以不存在。
创建外联接视图:
create view user_stu_view as select u.id,u.user_name,u.password,s.ddress from user_tbl u,stu_tbl s
where u.s_id(+)=s.id;--若哪一方带有(+),哪一方就是次要的
删除视图:
drop user_stu_view;
索引
用于提高SQL语句执行的性能
索引类型:
唯一索引,位图索引,组合索引,基于函数的索引,反向键索引。
创建标准索引:
create index user_id_index on user_tbl(id) tablespace schooltbs;
重建索引:
alter index user_id_index rebuild;
删除索引:
drop index user_id_index;
创建唯一索引:
create unique index user_id_index on user_tbl(id);
创建组合索引:
create index name_pass_index on user_tbl(user_name,password);
创建反向键索引:
create index user_id_index on user_tbl(id) reverse;