Oracle 查询各表空间使用情况--完善篇 链接:http://blog.itpub.net/28602568/viewspace-1770577/ 标题: Oracle 查询各表空间使用情况--完善篇 作者:lōττéry©版权所有[文章允许转载,但必须以链接方式注明源地址,否则追究法律责任.] 前言 :   之前简单写过"Oracle 查询各个 “表空间/数据文件” 的空间使用比情况",当时只简单用到dba_data_file"总大小"与dba_free_sp…
Oracle建立索引的目的是为了避免全表扫描,提高查询的效率. 但是有些情况下发现即使建立了索引,但是写出来的查询还是很慢,然后会发现是索引失效导致的,所以需要了解一下那些情况会导致索引失效,即查询不走索引. 在写SQL的层面上一些骚操作会导致索引失效: 没有写WHERE子句或查询条件没有建立索引 既然没有WHERE子句,那么就是查询全部数据了,相当于全表扫描,当然不走索引了. 而查询条件上没有建立索引的话,都没有你还走个毛索引啊. WHERE子句上没有使用索引中的引导列 要使用索引,则查询条件…
(一)索引失效的原因分析: <>或者单独的>,<,(有时会用到,有时不会) 有时间范围查询:oracle 时间条件值范围越大就不走索引 like "%_" 百分号在前. 表没分析(统计信息最好定期收集,以业务的不同确定不同的收集周期,在新增的索引有可能没有收集 ,那么就会导致索引失效) 解决方法: 分析方法有一下几种: analyze table t1 compute statistics fortable; --针对表收集信息 analyze table t2…
  查询数据库的锁表情况语句如下: SELECT p.spid,a.serial#, c.object_name,b.session_id,b.oracle_username,b.os_user_name FROM v$process p,v$session a, v$locked_object b,all_objects c WHERE p.addr=a.paddr AND a.process=b.process AND c.object_id=b.object_id 如果表因为某些情况出现死…
查询用户的索引select index_name,table_name,tablespace_name, index_type,uniqueness , status from dba_indexes where owner='SCOTT';查询用户的索引列select index_name,table_name,column_name, index_owner,table_ownerfrom dba_ind_columnswhere table_owner='SCOTT';查看索引的各种初始化…
总结一下oracle中会使索引无效的情况 1 无where条件: 2 索引列进行运算时: 3 使用like,并且通配符在前的情况: 4 字符型字段为数字时在where条件里不添加引号: 5 not in ,not exist: 6 当变量采用的是times变量,而表的字段采用的是date变量时.或相反情况: 7 单独引用复合索引里非第一位置的索引列: 8 如果column1和column2是同一个表的字段,含有条件column1 < column2或column1 > column2或colu…
1.查找表的所有索引(包括索引名,类型,构成列): select t.*,i.index_type from user_ind_columns t,user_indexes i where t.index_name = i.index_name and t.table_name = i.table_name and t.table_name = 要查询的表 2.查找表的主键(包括名称,构成列): select cu.* from user_cons_columns cu, user_constr…
优化一个sql,就是有A,B两个表,要利用b表的字段更新a表对应的字段.形如 Sql代码 update A set A.a=(select B.b from B where A.id=B.id); 原SQL updatepntmall_rptpoint_detail a set a.scrm_rptpnt_processed=( select distinctb.scrm_rptpnt_processed  frompntmall_rptpoint_detail_tmp b where a.pn…
ORACLE: 1.查主键名称: select * from user_constraints where table_name = 'AAA' and constraint_type ='P'; 查主键对应的列: select * from user_cons_columns where table_name = 'AAA' and constraint_name = 'PK_AAA'; (PK_AAA 是主键名) 2.查索引名称: select * from user_indexes whe…
分析索引空间使用情况.以及索引是否须要重建 分析其它用户下的索引须要 analyze any的权限 分析索引前先查看表的大小和索引的大小,假设索引大小和表大小一样大或者大于表的大小,那么能够推断索引可能有问题.须要分析索引 查询对象大小: select owner,segment_name,segment_type,bytes/1024/1024 from dba_segments order by 4 desc  1.分析索引 SQL> analyze index AA.INDEX_AA va…