Oracle Certification skillfully taking outside designated records associated with the alternative in / not in query

Oracle Certification skillfully taking outside designated records associated with the alternative in / not in query

Table 1 to obtain the first 6 to Article 10 of the value of records

1.1 The first method, the use of minus statement

Ddl statement assumptions are as follows:

CREATE TABLE T (ID VARCHAR2 (4) PRIMARY KEY, VALUE INT)

The first method is then removed before the 5, and then removed before 10, and then using the method of computing a collection of the former 10 minus 5 on the OK before the, SQL statement is as follows

The following is a quoted fragment:
SELECT * FROM T WHERE ROWNUM <= 10
MINUS
SELECT * FROM T WHERE ROWNUM <= 5;

1.2 In addition a method of using subquery

This kind of subquery approach is relatively complex, but a collection of performance than just subtract better. This method first subquery to be 10 before the data has also been made way before the 10 data rownum, and then once again just made inquiries when rownum query the data of more than 5. SQL statement is as follows

The following is a quoted fragment:
SELECT ID, VALUE FROM
(SELECT ID, VALUE, ROWNUM R FROM T WHERE R <= 10)
WHERE
R> 5;

Through the above statement, it has been 6 to Article 10 of the data.

2 the use of an alternative not in outer join statement

in statements are not in the statement of the efficiency is very poor, because the database in the face of these two statements, when data is to a more than a right, if in or not in the amount of data on both sides in the last million of the time, to compare the number of the million is very likely a simple sql statement to be performed for more than half an hour. This efficiency can not be sure that customers are acceptable. Then we can consider two alternative methods, the first statement is based on the exist and not exist statement, which we should be more familiar with. Another is outside the associated statement Using this method may not be familiar with everyone, I came to talk about a little. Hypothetical data table DDL statements to build tables for the

CREATE TABLE T1 (ID VARCHAR2 (4) PRIMARY KEY, VALUE INT)

And in the table or not in the building table for DDL statements

CREATE TABLE T2 (VALUE INT)

Oracle is used by Chinese and foreign association (+) symbol outside the association, that is to say a logo (+) symbols of value can not find the time corresponding to NULL. The following is a statement of when to replace in the SQL statement

The following is a quoted fragment:
SELECT T1.ID, T1.VALUE
FROM T1, T2
WHERE T1.VALUE = T2.VALUE (+)
AND T2.VALUE IS NOT NULL;

And similar. Alternative not in the SQL statement of the statement when compared with

The following is a quoted fragment:
SELECT T1.ID, T1.VALUE
FROM T1, T2
WHERE T1.VALUE = T2.VALUE (+)
AND T2.VALUE IS NULL;

We can test, in the amount of data and more time than the use of external linkages in or not in the implementation of the efficiency of many, many higher.
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Oracle Certification skillfully taking outside designated records associated with the alternative in / not in query

  • ORACLE10G full version centos5 installed (the installation has passed)

    ORACLE10G full version centos5 installed (the installation has passed) 1. Centos 5.0 install rn GUI must be installed, it is best not to start selinux rn rn rn 2. . Ready to install the software: (this is very important, is the first installation fai ...

  • SGA extended the principle of 32bit oracle

    SGA extended the principle of 32bit oracle From: http://www.itpub.net/247048.html Because the median 32bitrnoracle restrictions can only visit the oracle process 4g (2 of 32 power) following virtual memory address, the time at a lot of people this is ...

  • SQL optimization (1) - full table scan and index the test

    Test Objective: To test CBO and RBO, as well as full table scan than index the situation quickly. 1. To create a test environment SQL> select * from v $ version; BANNER -------------------------------------------------- -------------- Oracle Datab ...

  • Dbms_obfuscation_toolkit use of Oracle's encryption and decryption of data (to)

    In order to protect sensitive data, oracle start from 8i to provide a data encryption package: dbms_obfuscation_toolkit. Take advantage of this package, our data can be DES, Triple DES or MD5 encryption. This article on the use of this and the use of ...

  • Oracle XDB relax resolve port conflict of 8080

    In this paper, carried: http://www.enet.com.cn/article/2008/0306/A20080306175452.shtml Oracle 9i from the start, Oracle includes the installation of the default XDB. After starting the database, Oracle XDB's http service will automatically take u ...

  • Oracle in the relationship between User and Schema

    If we want to know the database and the User What is the relationship between Schema, we must first know about User and Schema database What is the concept in the end. In SQL Server2000 in architecture because of the reason, User and Schema there is ...

  • High Availability Oracle Flashback

    Brief introduction Flashback Database is a point in time (PIT) restore the database approach. This incomplete recovery strategy can be used to restore the logic because of human error cause damage to the database. At the introduction of 10g, it is de ...

  • An example of the use of TKPROF

    First, view and edit parameters SQL> show parameter max_dump_file_size NAME TYPE VALUE ------------------------------------ ----------- --- --------------------------- max_dump_file_size string UNLIMITED SQL> show parameter user_dump_dest NAME TYPE

  • Diagnosis and principles of order

    SQL> select disk.value "Disk", mem.value "Mem", 2 (disk.value / mem.value) * 100 "Ratio" 3 from v $ sysstat mem, v $ sysstat disk 4 where mem.name = 'sorts (memory)' 5 and disk.name = 'sorts (disk)'; D ...

  • ORACLE 10G dataguard configuration Step by Step

    oracle dataguard

Leave a Reply

Recent
Recent Entries
Tag Cloud
Random Entries
Latest Comments