`
lobin
  • 浏览: 417637 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

ORACLE

 
阅读更多

ORACLE SQL优化 - ORACLE执行计划

Last login: Mon Feb  8 14:13:19 2010 from 192.168.1.249

 

ipnet

-bash-3.00$ 

-bash-3.00$ ipnet

-bash: ipnet: command not found

-bash-3.00$ su - oracle

Password: 

eastcsu: incorrect password

-bash-3.00$ eastcom

-bash: eastcom: command not found

-bash-3.00$ su - oracle

Password: 

[oracle@ipnet-td2 ~]$ 

 

[oracle@ipnet-td2 ~]$ sqlplus /nolog

 

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 8 14:14:08 2010

 

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

 

SQL> su^H^H^H

SP2-0042: unknown command " - rest of line ignored.

SQL> conn ipnet/ipnet1234@ORAC^H^H^H

ERROR:

ORA-12154: TNS:could not resolve the connect identifier specified

 

 

SQL> ^[[A^H               " - rest of line ignored.

SQL> 042: unknown command "

SQL> conn ipnet/ipnet1234@ORCL 

Connected.

SQL> set timn^H

SP2-0158: unknown SET option "tim"

SQL> set timing on

SQL> set autot traceonly

SQL> select v.NAME_CN from vendor v, vendordevicetype vt, devicetype t where t.name = vt.device_type_name and v.name = vt.vendor_name and t.name_cn = '防火墙';

 

Elapsed: 00:00:00.01

 

Execution Plan

----------------------------------------------------------

Plan hash value: 497066359

 

--------------------------------------------------------------------------------

------------------

 

| Id  | Operation                     | Name             | Rows  | Bytes | Cost

(%CPU)| Time     |

 

--------------------------------------------------------------------------------

------------------

 

|   0 | SELECT STATEMENT              |                  |     5 |   205 |     7

   (0)| 00:00:01 |

 

|   1 |  NESTED LOOPS                 |                  |     5 |   205 |     7

   (0)| 00:00:01 |

 

|   2 |   NESTED LOOPS                |                  |     5 |   140 |     4

   (0)| 00:00:01 |

 

|*  3 |    TABLE ACCESS FULL          | DEVICETYPE       |     1 |    14 |     3

   (0)| 00:00:01 |

 

|   4 |    TABLE ACCESS BY INDEX ROWID| VENDORDEVICETYPE |     5 |    70 |     1

   (0)| 00:00:01 |

 

|*  5 |     INDEX RANGE SCAN          | N907275051_IDX   |     5 |       |     0

   (0)| 00:00:01 |

 

|   6 |   TABLE ACCESS BY INDEX ROWID | VENDOR           |     1 |    13 |     1

   (0)| 00:00:01 |

 

|*  7 |    INDEX UNIQUE SCAN          | NAME_4_1         |     1 |       |     0

   (0)| 00:00:01 |

 

--------------------------------------------------------------------------------

------------------

 

 

Predicate Information (identified by operation id):

---------------------------------------------------

 

   3 - filter("T"."NAME_CN"='防火墙')

   5 - access("T"."NAME"="VT"."DEVICE_TYPE_NAME")

   7 - access("V"."NAME"="VT"."VENDOR_NAME")

 

 

Statistics

----------------------------------------------------------

          1  recursive calls

          0  db block gets

         18  consistent gets

          0  physical reads

          0  redo size

        466  bytes sent via SQL*Net to client

        385  bytes received via SQL*Net from client

          2  SQL*Net roundtrips to/from client

          0  sorts (memory)

          0  sorts (disk)

          3  rows processed

 

SQL> 

 

 

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jxluoix/archive/2010/02/08/5298961.aspx

 

 

Oracle 查询 删除 重复记录

 

select t.*, t.rowid from test_select_delete_dump_rd t;


-- 查询表中存在重复记录的所有记录
select t.*, t.rowid from test_select_delete_dump_rd t
    where
    name in (
        select name from test_select_delete_dump_rd
            group by name
            having count(name) > 1
    );


-- 查询表中存在重复记录的多余记录,
-- rowid最小的记录被认为是保留记录
select * from (
    select t.*, t.rowid  from test_select_delete_dump_rd t
        where
        name in (
            select name from test_select_delete_dump_rd
                group by name
                having count(name) > 1
        )
) t2
    where
    t2.rowid not in (
        select min(t1.rowid) from test_select_delete_dump_rd t1
            group by name
            having count(name) > 1
    );

   
-- 查询表中存在重复记录的多余记录,
-- rowid最大的记录被认为是保留记录
select * from (
    select t.*, t.rowid  from test_select_delete_dump_rd t
        where
        name in (
            select name from test_select_delete_dump_rd
                group by name
                having count(name) > 1
        )
) t2
    where
    t2.rowid not in (
        select max(t1.rowid) from test_select_delete_dump_rd t1
            group by name
            having count(name) > 1
    );

/**
delete from test_select_delete_dump_rd
    where
    name in (
        select name from test_select_delete_dump_rd
            group by name
            having count(name) > 1
    )
    and
    rowid not in (
        select min(name) from test_select_delete_dump_rd
            group by name
            having count(name) > 1
    );
*/

 

 

 

 

 

 

 

dense_rank, rank:

 

 

select * from (
    select deptno, ename, sal,
        dense_rank() over(
            partition by deptno
            order by sal desc
        ) dr
    from emp
)
where dr <= 3
order by deptno, sal desc;

 

 

 

 

 


select * from (
    select deptno, ename, sal,
        rank() over(
            partition by deptno
            order by sal desc
        ) dr
    from emp
)
where dr <= 3
order by deptno, sal desc;

  • 大小: 14.6 KB
  • 大小: 14.3 KB
  • 大小: 18.9 KB
  • 大小: 22.2 KB
0
0
分享到:
评论

相关推荐

    Oracle 9i Client (Oracle 9i 客户端) 简化版 (不安装Oracle客户端,也可以使用PLSQL Developer)

    Oracle 9i Client (Oracle 9i 客户端) 简化版 (不安装Oracle客户端,也可以使用PLSQL Developer 不用安装Oracle客户端也可以使用PLSQL Developer 绿色! 安全! 轻便! 可靠! 1、本软件可作为简单的Oracle9i客户端...

    oracle10G和oracle11G的OCI.dll

    oci.dll是Oracle Call Interface的缩写,它是Oracle数据库的一个核心组件,允许开发者使用各种编程语言与Oracle数据库进行交互。在Oracle 10G和11G版本中,oci.dll扮演了至关重要的角色,为应用程序提供了访问数据库...

    oracle.jdbc.driver.oracledriver Oracle JDBC驱动包 ojdbc6

    Oracle JDBC驱动包是Oracle数据库与Java应用程序之间进行通信的关键组件,它使得Java程序员能够通过编写Java代码来操作Oracle数据库。标题中的"ojdbc6"指的是Oracle JDBC驱动的一个特定版本,适用于Java SE 6环境。...

    cx_Oracle使用手册

    cx_Oracle是Python编程语言中用于连接Oracle数据库的一个模块。该模块遵循Python数据库API规范,并且适用于Oracle 11.2和12.1版本,同时兼容Python 2.x和3.x版本。cx_Oracle模块通过使用Oracle客户端库来实现与...

    Python连接oracle工具cx_Oracle官方文档

    cx_Oracle是Python数据库API规范的实现,用于访问Oracle数据库。目前,该模块经过对Oracle客户端版本11.2、12.1和12.2以及Python版本2.7、3.4、3.5和3.6的测试。cx_Oracle遵循开源的BSD许可证,这表示用户可以自由地...

    基于C#连接Oracle数据库Oracle.ManagedDataAccess

    首先,Oracle.ManagedDataAccess是Oracle公司提供的一个纯.NET框架的客户端驱动,它允许开发者在不安装Oracle客户端的情况下,直接与Oracle数据库进行交互。这个库包含了所有必要的组件,使得C#程序可以方便地执行...

    《Oracle 12c数据库基础教程》教学课件—03Oracle数据库管理工具.pdf

    《Oracle 12c数据库基础教程》教学课件—03Oracle数据库管理工具.pdf《Oracle 12c数据库基础教程》教学课件—03Oracle数据库管理工具.pdf《Oracle 12c数据库基础教程》教学课件—03Oracle数据库管理工具.pdf《Oracle...

    Mysql转Oracle软件 DBMover for Mysql to Oracle

    Dbmover for Mysql to Oracle 是高效的将Mysql导入到Oracle数据库的工具。 使用DBMover可以灵活定义Mysql和Oracle之间表和字段的对照关系,也可以在DBMover创建一个查询,把查询结果当作源表转入到Oracle中。 ...

    OracleClient-19C Oracle客户端,包括windows和Linux

    Oracle Client是Oracle公司提供的数据库连接工具,用于与Oracle数据库服务器进行通信。19C是Oracle Database的一个版本,代表第19个主要版本。这个压缩包包含的Oracle Client适用于Windows和Linux操作系统,使得...

    Oracle Ojdbc各版本驱动包

    Oracle各版本驱动包,有需要的可以下载使用,支持目前常用的不同版本oracle和JDK,根据自己需要调整和使用 主要包括的jar有: ojdbc5.jar 适用JDK版本:JDK 1.5 对应Oracle数据库版本:Oracle数据库版本(如Oracle ...

    Oracle11g客户端精简版

    Oracle 11g客户端是Oracle数据库的一个轻量级版本,主要供开发人员和系统管理员用于连接到Oracle数据库服务器,执行查询、管理和维护数据库任务。这个精简版在保持基本功能的同时,减少了安装体积,便于快速部署和...

    Tianlesoftware Oracle 学习手册(v1.0)高清完整PDF版

    ### Tianlesoftware Oracle 学习手册(v1.0)中的关键知识点 #### 1. ORACLE基础知识 ##### 1.1 OLAP与OLTP介绍 **1.1.1 什么是OLTP** OLTP(Online Transaction Processing,在线事务处理)是一种主要针对企业...

    利用python-oracledb库连接Oracledb数据库,使用示例

    python-oracledb的源码和使用示例代码, python-oracledb 1.0,适用于Python versions 3.6 through 3.10. Oracle Database; This directory contains samples for python-oracledb. 1. The schemas and SQL ...

    Oracle 11g 客户端工具 精简版 Oracle Client

    Oracle 11g客户端工具是Oracle数据库系统的重要组成部分,它为开发者和DBA提供了一系列用于连接、管理和维护Oracle服务器的实用程序。精简版的Oracle Client通常包含了最基础且常用的组件,适合那些只需要进行基本...

    Oracle19c-Windows客户端

    Oracle 19c是Oracle数据库的一个重要版本,尤其在Windows平台上,它提供了全面的功能和优化,使得数据库管理和开发更为高效。以下将详细讲解Oracle 19c Windows客户端的关键知识点: 1. **Oracle Client**: Oracle...

    oracle经典书籍(Oracle 9i初学者指南.zip、Oracle专家高级编程.pdf、Effective+Oracle+by+Design.pdf)

    这里提到的三本书籍——"Oracle 9i初学者指南.zip"、"Oracle专家高级编程.pdf"以及"Effective Oracle by Design.pdf"都是Oracle学习者和专业开发者的宝贵资源。 "Oracle 9i初学者指南.zip":这是一本针对Oracle 9i...

    Veeam 备份恢复oracle数据库详细配置文档

    Veeam 备份恢复 Oracle 数据库详细配置文档 本文档旨在详细介绍如何使用 Veeam 备份恢复 Oracle 数据库的配置过程。该文档将指导读者从环境准备到推送 Oracle RMAN Plugin,再到创建备份作业和运行备份作业,最后...

    oracle 客户端 64位

    Oracle客户端是用于与Oracle数据库服务器交互的软件工具,主要功能是提供对数据库的查询、更新、管理等操作。Oracle客户端支持多种操作系统,包括Windows,且有32位和64位之分。在这个场景中,我们关注的是"Oracle...

    解决System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本

    标题中的“System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本”是一个常见的错误提示,它涉及到在.NET环境中使用Oracle数据库时遇到的问题。这个错误表明,当你试图在应用程序中使用System.Data....

    Oracle Instant Client 11.2.0.1.0 轻量级Oracle客户端

    Oracle Instant Client 11.2.0.1.0是轻量级Oracle客户端,用于连接访问Oracle 9i、10g、11g 11.2.0.1.0版本的Oracle数据库。 Oracle Instant Client11.2.0.1.0 安装程序包含OCI/ OCCI、JDBC-OCI SDK(软件开发工具...

Global site tag (gtag.js) - Google Analytics