Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2015
    Posts
    1

    Unanswered: Oracle BTREE index creation in WITH clause

    Can we create a btree index on a column in a WITH clause. For instance, the below WITH clause is having diagnosis codes and its decriptions in a table where this WITH clause is joined to another WITH clause or any other persistent table in a schema and diagnosis code column is used in where clause multiple times.

    WITH DIAG AS
    ( /*+CREATE BTREE INDEX INDX_BTREE ON DIAG(DIAGNOSIS_CODE) LOCAL */
    SELECT DIAGNOSIS_PK,
    DIAGNOSIS_CODE, -- HOLDS UNIQUE VALUES AND IS REFERRED IN WHERE CLAUSE NEXT LEVELS
    DIAGNOSIS_DESC
    FROM DIAGNOSIS_TABLE
    )

    SELECT CLAIM.*
    FROM SCHEMA.CLAIM_TABLE CLAIM
    INNER JOIN DIAG
    ON DIAG.DIAGNOSIS_CODE = CLAIM.DIAGNOSIS_CODE
    WHERE
    DIAGNOSIS_CODE IN ('','')
    OR DIAGNOSIS_CODE LIKE 'V6%'

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >Can we create a btree index on a column in a WITH clause.
    no

    What is wrong with just doing as below?
    CREATE INDEX INDX_BTREE ON DIAGNOSIS(DIAGNOSIS_CODE);
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by vkavala View Post
    Can we create a btree index on a column in a WITH clause
    No.
    You can only create indexes on tables (or materialized views). A common table expression is not a table, so it cannot be indexed.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •