关于oracle 索引

创建唯一索引,ind_name为索引名称,TBS为存放索引段的表空间.(索引表空间)
create unique index ind_name on table_name(col_name) tablespace tbs;


重建索引,如果一个索引创建了很长时间就会产生碎片从而影响查询性能,这时需要重建索引.rebuild意思为重建
alter index ind_name rebuild;


有时候由于空间的调整,把索引从一个表空间移到另外一个表空间
1.先查看当前所在的表空间

select index_name,tablespace_name from dba_indexes where index_name='INDEX_PS';
2.移到另外一个product表空间

alter index index_ps rebuild tablespace product;
3.再次查看表空间,确定索引是否成功移到另一个表空间
select index_name,tablespace_name from dba_indexes where index_name='INDEX_PS';


查看创建索引都语句

set long 10000;
select dbms_metadata.get_ddl('INDEX','IND_NAME','ZWC');

 

1.创建表,通过utlxplan.sql脚本
SQL> @?/rdbms/admin/utlxplan.sql
2. 创建同义词为了多个用户可以共享一个plan_table 并授权给public
SQL> create public synonym plan_table for plan_table;
SQL> grant all on plan_table to public;
3.创建plustrace 角色
SQL> @?/sqlplus/admin/plustrce.sql 执行这个脚本就可以了。
4、将角色权限授予public
sql>grant plustrace to public;
完成以上几步就可以使用autotrace 功能
set timing on --显示执行时间
set autotrace on 查看执行计划和查询信息
set autotrace traceonly 只显示执行计划,但不显示查询输出

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值