一、explain plan

a)explain plan for select ...

select * from table(dbms_xplan.display());

function display (table_name   varchar2 default 'PLAN_TABLE',
                  statement_id varchar2 default null,
                  format       varchar2 default 'TYPICAL')

- table_name:
      specifies the table name where the plan is stored. This
      parameter defaults to "PLAN_TABLE" which is the default
      plan table for the explain plan.

- statement_id:
      specifies the statement id of the plan to display. This
      parameter defaults to NULL.

- format:
     'BASIC':   Display only the minimum, i.e. the operation id, 
                the operation name and its option
     'TYPICAL': This is the default. Display most information
                of the explain plan (operation id, name and option,
                #rows, #bytes and optimizer cost. Pruning, 
                parallel and predicate information are only 
                displayed when applicable.
     'ALL':     Maximum level. Like typical with additional display
                of the SQL statements generated for PX servers
                (only if parallel). 
     'SERIAL':  Like typical except that parallel information are
                  not displayed, even if the plan is parallel

b)dbms_xplan.display_awr(sql_id VARCHAR2,
plan_hash_value INTEGER DEFAULT NULL,
db_id           INTEGER DEFAULT NULL,
format          VARCHAR2 DEFAULT 'TYPICAL')
RETURN dbms_xplan_type_table PIPELINED;

c)dbms_xplan.display_cursor(
sql_id          VARCHAR2 DEFAULT NULL,
cursor_child_no INTEGER DEFAULT 0,
format          VARCHAR2 DEFAULT 'TYPICAL')
RETURN dbms_xplan_type_table PIPELINED;

select child_number from v$sql_shared_cursor where sql_id='...';

d)dbms_xplan.display_sqlset(
sqlset_name     VARCHAR2,
sql_id          VARCHAR2,
plan_hash_value INTEGER DEFAULT NULL,
format          VARCHAR2 DEFAULT 'TYPICAL',
sqlset_owner    VARCHAR2 DEFAULT NULL)
RETURN dbms_xplan_type_table PIPELINED;

2、v$sql_shared_cursor的reason为OPTIMIZER_MISMATCH—优化器环境与现有的子游标不匹配时括号中的数字意义
1 = Degree used is not the default DOP
2 = In (RAC) cases where instance count is not the same, or session CPU count is not the same, or thread count is not the same
3 = _parallel_syspls_obey_force is FALSE
4 = The PQ mode does not match.
5 = The degree does not match.
6 = The parallel degree policy does not match.
7 = The session limit is not the same as the cursor limit but the cursor limit is the same as the degree used.
8 = The cursor limit is greater than the degree used and the session limit is less than the cursor limit
9 = The cursor limit is less than the degree used and the session limit is not the same as the cursor limit
10 = Optimizer mode difference
11 = Materialized View mismatch
12 = Optimizer environment mismatch (ie an optimizer parameter is different)
13 = Cardinality Feedback is use

二、sqlplus启动执行命令

[$ORACLE_HOME/sqlplus/admin,$SQLPATH,.]\glogin.sql,login.sql

显示所有参数

show all

show user,show error

三、sql多行结果转一行

select i,wmsys.wm_concat(a) from t group by i;

四、当前session_id

select sid, serial#, status from v$session where audsid=userenv('sessionid');

select sid from v$mystat where rownum=1;

select userenv('sid') from dual;

五、flashback

db_recovery_file_dest:指定闪回恢复区的位置
db_recovery_file_dest_size:指定闪回恢复区的可用空间大小
db_flashback_retention_target:指定数据库可以回退的时间,单位为分钟,默认1440分钟,也就是一天。

v$flash_recovery_area_usage:    flash_recovery_area空间使用情况(分类)

v$recovery_file_dest:  空间使用

dba_outstanding_alerts:空间告警

V$CONTROLFILE, V$LOGFILE, V$ARCHIVED_LOG, V$DATAFILE_COPY 等数据字典的列IS_RECOVERY_DEST_FILE ,指明相关的文件是否在恢复区内

六、数据字典

select reason,object_type,suggested_action,creation_time from dba_outstanding_alerts;
性能、资源相关告警,补充alert
select * from v$resource_limit;
资源使用历史

七、闪回查询

利用undo

当前scn
select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') time, to_char(dbms_flashback.get_system_change_number) scn from dual;
Scn转换成时间:
select to_char(scn_to_timestamp(3998591352171),'YYYY-MM-DD HH24:MI:SS') from dual;
时间转换成scn:
select timestamp_to_scn(to_date('2011-04-14 11:10:25','YYYY-MM-DD HH24:MI:SS')) from dual;
查询该时间点(或scn)的数据,如下:
select * from t as of timestamp to_timestamp('2000-01-01 01:01:01', 'yyyy-mm-dd hh24:mi:ss');
select * from t as of scn xxx;

oracle备忘的更多相关文章

  1. 项目中oracle存储过程记录——经常使用语法备忘

    项目中oracle存储过程记录--经常使用语法备忘 项目中须要写一个oracle存储过程,需求是收集一个复杂查询的内容(涉及到多张表),然后把符合条件的记录插入到目标表中.当中原表之中的一个的日期字段 ...

  2. Oracle使用备忘

    初学Oracle,很多语句记不住,写在这里备忘. 1.查看某表空间的数据文件 select file_name 文件名, tablespace_name 表空间名, bytes 已使用大小M, max ...

  3. JVM内存知识备忘

    又是一篇备忘... 主要记录一些知识,进行一些资源的汇总. 先来群里liufor大大提供的两张图,清晰易懂: Dockerized Java https://www.youtube.com/watch ...

  4. 工作T-SQL备忘

    作为一个"浸淫" Oracle 数据库很久的人来说, 突然转入 T-SQL, 也就是 MSSQL , 工作中经常用的查询和 MSMS 使用备忘如下 : --1. 切换对应的库连接 ...

  5. Annotation 使用备忘

    title: Annotation 使用备忘 date: 2016-11-16 23:16:43 tags: [Annotation] categories: [Programming,Java] - ...

  6. GIS部分理论知识备忘随笔

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.高斯克吕格投影带换算 某坐标的经度为112度,其投影的6度带和3度带 ...

  7. python序列,字典备忘

    初识python备忘: 序列:列表,字符串,元组len(d),d[id],del d[id],data in d函数:cmp(x,y),len(seq),list(seq)根据字符串创建列表,max( ...

  8. Vi命令备忘

    备忘 Ctrl+u:向文件首翻半屏: Ctrl+d:向文件尾翻半屏: Ctrl+f:向文件尾翻一屏: Ctrl+b:向文件首翻一屏: Esc:从编辑模式切换到命令模式: ZZ:命令模式下保存当前文件所 ...

  9. ExtJs4常用配置方法备忘

    viewport布局常用属性 new Ext.Viewport({ layout: "border", renderTo: Ext.getBody(), defaults: { b ...

随机推荐

  1. nova boot instance call flow

    参考http://www.cnblogs.com/popsuper1982/p/3927390.html

  2. SQL2005:SQL Server 2005还原数据库时出现“不能选择文件或文件组XXX_log用于此操作的解决办法

    SQL2005 还原数据库失败,提示如下: SQL Server 2005还原数据库时出现“不能选择文件或文件组XXX_log用于此操作的解决办法 出现错误时操作步骤为:右击数据库--->任务- ...

  3. Delphi 使用CHM文件制作系统帮助文档(上下文感知帮助的制作)

    一.基础知识简介         使用帮助提示窗口或状态栏只能提供简单.单一的帮助,无法对某一模块或应用程序整体提供系统的 帮助,因此运行Windows应用程序,需要帮助时一般都可以通过执行帮助菜单获 ...

  4. Eplan PPE Pro-panel Electric fluid P8 2.4图文安装教程

    Eplan ppe pro-panel electric fluid P8等多个最新2.4中文版本的安装,都是使用相同的虚拟驱动MultiKey,还是只有win32位的安装包,不过支持64位操作系统的 ...

  5. C++中没有finally,那么应该在如何关闭资源

    这是一篇有趣的帖子 原文链接: http://bbs.csdn.net/topics/90070457 楼主: C++中没有finally,那么应该在哪里关闭资源? C++的try{}catch(){ ...

  6. 甲状腺癌怎样早发现 可B超检查

    2013-12-13 14:40:00.0 本文来源:人民网 点击参与跟帖 原标题:健康之道:甲状腺癌怎样早发现 摘要:甲状腺癌怎样早发现呢?隐早期以甲状腺结节的方式存在,且以匿方式生长,可能在人们偶 ...

  7. 2. xargs 命令

    1.简介 xargs是给命令传递参数的一个过滤器,也是组合多个命令的一个工具.它把一个数据流分割为一些足够小的块,以方便过滤器和命令进行处理.通常情况下,xargs从管道或者stdin中读取数据,但是 ...

  8. js实现缓冲运动,和匀速运动有点不相同

    缓冲运动和匀速运动有点不同,看图可以知道缓冲运动速度是越来越慢的. <style> *{ padding:0; margin:10px 0; } #div1{ height:100px; ...

  9. JS中插入节点的方法appendChild和insertBefore的应用

    1.appendChild() 方法:可以向节点的子节点列表的末尾添加新的子节点.比如:appendChild(newchild)括号里可以是创建的标签var newchild = document. ...

  10. java泛型中的super和extend

    List<? extend Fruit> list=new ArrayList<>();  解释为:集合中元素是继承自Fruit,究竟是何种类型,编译器也无法判定. 如果要从集 ...