Index on multiple columns issue Oracle 9i

Hi,
I have a couple of issues and would appreciate it if anyone can help:
a). I have a table that has indexes on multiple columns, so for example:
Index 1 on Org_Type, Org_Id and Effdt
Index 2 on FICE_CD, Org_Id and Effdt etc.
I have 9 such indexes and all of them hav Effdt in it.
My question is if I query the table and always use a subquery to get the max Effdt rows form the table, will the above indexes help in my query or will I have to create another index just on Effdt so that my Query runs faster.
b). I have a target table with more than 20 million rows in it. This table has an Effdt too and I would like to find the max effdted row in this table as well so that I can then use that date-time stamp in my ETL tool to do an incremental update from my source table each night. But since the amount of rows is huge, my query runs forever. I have a normal non-unique index on Effdt. Is there another way I can optimize this table? Currenlty I have resorted to getting all rows from source that are >= (sysdate -1), but I would prefer to get the max date-time stamp from the target table itself.
Thanks,
CJ

Hi ,
Thanks for the input. I just used the explain plan and found that there is a full table scan happening on the PS_EXT_ORG_TBL, so I guess I will have to create an index specifically on the effdt field. The sql is as follows:
Select E.EMPLID, E.INSTITUTION, E.EXT_ORG_ID, E.EXT_CAREER, E.EXT_DATA_NBR, E.EXT_SUMM_TYPE, E.UNT_ATMP_TOTAL, E.UNT_COMP_TOTAL,
E.CLASS_RANK, E.CLASS_SIZE, E.PERCENTILE, E.UM_GPA_EXCLUDE, E.UM_EXT_ORG_GPA, E.CONVERT_GPA,
E.UM_EXT_ORG_CNV_CR, E.UM_EXT_ORG_CNV_GPA, E.UM_EXT_ORG_CNV_QP, E.UM_GPA_OVERRIDE, E.EXT_ACAD_LEVEL,
F.FROM_DT, F.TO_DT, G.EXT_DEGREE_NBR, G.DEGREE, G.DESCR "DEGREE DESCR", G.DEGREE_DT, H.EFFDT,
H.EFF_STATUS, H.SCHOOL_CODE, H.LS_SCHOOL_TYPE, H.ATP_CD, H.CITY, H.STATE, H.COUNTRY,
H.DESCR "SCHOOL DESCR", H.PROPRIETORSHIP
FROM PS_EXT_ACAD_SUM E, PS_EXT_ACAD_DATA F, PS_EXT_DEGREE G, PS_EXT_ORG_TBL H
WHERE E.EXT_ORG_ID = F.EXT_ORG_ID AND E.EMPLID = F.EMPLID
AND E.EXT_ORG_ID = G.EXT_ORG_ID AND E.EMPLID = G.EMPLID
AND E.EXT_ORG_ID = H.EXT_ORG_ID
AND H.EFFDT=(SELECT MAX(EFFDT) FROM PS_EXT_ORG_TBL H1
          WHERE H.EXT_ORG_ID=H1.EXT_ORG_ID
                    AND H.EFF_STATUS=H1.EFF_STATUS
                    AND H.SCHOOL_CODE=H1.SCHOOL_CODE
                    AND H.LS_SCHOOL_TYPE=H1.LS_SCHOOL_TYPE
                    AND H.ATP_CD=H1.ATP_CD
                    AND H.CITY=H1.CITY
                    AND H.STATE=H1.STATE )
My source DB is a copy of the transactional database, so there is no danger of new rows coming in.

Similar Messages

  • Indexes with multiple columns v/s multiple indexes with single column

    Hi Everyone,
    I have a table with below structure
    Create Table Test_Table
    Col1 int,
    Col2 int,
    Col3 int,
    Col4 int,
    Col5 int,
    Col6 int,
    Col7 int,
    Col8 bigint
    Col9 money
    Col10 money
    Now this table is being used in various reports. Since reports need various data, the filter clause for the report’s have various combination of table columns
    Example, Report 1 can have query like
    Select * from Test_Table where col1 = @val1
    Report 2:
    Select * from Test_Table where col1 = @val1 and col2 >=@val2
    Report3:
    Select * from Test_Table where col1 = @val1 and col2 >=@val2 and col3 =@val3 and col4 in(@val4)
    Report4:
    Select * from Test_Table where col1 = @val1 and col2 >=@val2 and col4 = @col4
    And many more combinations.
    Currently the table has many combinations of indexes
    Index1: col1, col2
    Index2: Col2
    Index3: col1, col2, col4
    Index4: col3 include (col9)
    Index5: col1, col2, col3, col4, col9
    Now I am into a performance issue where I have to create one more index with a slight variation from the existing combination of columns.
    Can you please let me know instead of having these various combination of indexes can I create multiple indexes on individual columns.
    Considering the above 4 examples which I have given for 4 reports, if I create 4 indexes separately on 4 individual columns col1, col2, col3, col4 will it be effective on all4 reports?
    Please suggest me the best way to create indexes on this table
    Thanks in advance,
    Raksha

    Do you really need to bring all columns ? Do not use SELECT *.
    Just a guess try index on col1, col2, col3, col4
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Format on multiple columns issue ...

    Post Author: needhelptoo
    CA Forum: Formula
    I'm having issues with the way the data is displaying.I am using the Format Multiple Columns.I have 3 across set.I have the Down and Across checked.My report with the 3 columns is a custom labels sheet.I need to have the down part always be 8 columns.i can't set that anywhere like the 3 columns across.as the sheet used to print the info are labels and perforated for each label (column)I have the following:1.
    Group Header #1 on InvoiceNumber. This have my invoice header
    information related to the customer of the invoice. Keep Together
    selected.2. Group Header #2 on a formula {@sort}. This is suppressed and as  a {@reset} formula in it.3. Details section has {@accum} and section suppressed. Keep Together selected.4. Group Footer #2 as the {@display} formula with Paragraph Formatting. Keep Together selected.5. Group Footer #1 on InvoiceNumber has add'l customer related info for the invoice.so 5 sections in my design view with 2 groups.It'll display the information in InvoiceNumber order in ascending order down first.But the last one on the 1st column is only part of the invoice info and the rest of it starts from the top of the 2nd column.and
    then shifts all the columns according to that. Which of course then
    does not print on the allotted space of the actual label. part of info
    is on one and the rest on another.obviously this won't work. I think i tried everything I can think of and I'm not expert. Barely a novice at this.any help would be appreciated!

    Post Author: V361
    CA Forum: Formula
    In the layout tab, have you tried the Gap between details ?, you should be able to produce a "mailing label type" report using detail size and gap between details... 

  • Multiple source columns from Oracle DB to Hyperion Essbase cube

    Hi Experts ,
    We have a Source as oracle table to the target Hyperion Essbase Cube(Planning) 11.1.2 using ODI 11g.
    Right now my issue is We need to map multiple columns from Oracle DB to One Dimension in Essbase (Planning).
    For example -> * In Oracle table i have columns as Name,Volume,unit and item *
    In Essbase the dimension called "*CatDefinition has lower level members as Name,Volume,unit and item * "
    Now using ODI ,* I want to map the oracle table columns(Multiple) to the dimension(Catdefinition) ? * Please suggest me with idea to achieve multiple column mapping to the single dimension in Essbase .
    Thanks in Advance !
    Keny Alex

    Do you even need FDM? You could build a load rule in Essbase directly. If you need to map, then you would register the Essbase target adapter.

  • Full text query across multiple columns

    In the SQL Server, when you do the full text query, you can specify multiple columns, e.g.
    FREETEXT ( { column_name | [b](column_list) | * } , 'freetext_string' [ , LANGUAGE language_term ] )
    CONTAINS ( { column_name | [b](column_list) | * } , '< contains_search_condition>' [ , LANGUAGE language_term ])
    Where,
    column_list Indicates that several columns, separated by a comma, can be specified...
    * Specifies that all columns in the table registered for full-text searching should be used to search for the given contains search condition. The columns in the CONTAINS clause must come from a single table...
    That makes full text query cross multiple columns very convenient. Are there any mechnisms in Oracle to do the same thing?
    Thanks in advance.

    Thanks for your reply.
    I knew that you could build full text index for the multiple columns using Oracle Text. But that does not solve my problem, which is how to build the query to search multiple columns at once. Say, I have columns firstname, lastname, address, and email in the table customers. I want to get the results that ANY column contains 'bob'. In SQL Server, I can do
    select * from customers where contains(*, 'bob')
    that is. But for Oracle, I have to do
    select * from customers where contains('firstname', 'bob') or contains('lastname', 'bob') or contains('address', 'bob') or contains('email', 'bob')
    Can you imagine if I have many columns in many tables and I have to do the query against all columns in all tables? I have to dynamically get all the columns and then build the query string.
    So, any better solutions?

  • Mapping a dimension to multiple columns

    Hi
    Is it possible to map a single dimension to multiple columns iin oracle olap ?

    No. This is very different from your original question. It seemed like you were asking if multiple columns can be used in the dimension mapping. Of course the answer is yes – it is designed that way.
    But re-using a single dimension multiple times in a cube makes no sense. You have to ask yourself if all 10 dimensions have the same business meaning to the end user. If all 10 dimensions have the same meaning, then you really only have 1 dimension. But if the meanings differ, then you need 10 separate dimensions.
    It may look like the dimension values are 0 and 1 in the table, but their meanings probably differ wildly (i.e. male/female; processed/unprocessed; cash/credit; true/false; east/west; sales associate/sales manager; etc.).

  • Indexing multiple columns in multiple tables

    I have a multiple tables in which I want to search. I need to do text search that supports fuzzy logic for which I've currently set up a context index using the user_datastore. I also need to search columns such as numbers/dates/timestamps which from what I understand is not supported with the context search. I'm looking at setting up a second index of type ctxcat for this purpose - but I will need to index multiple columns in multiple tables. Is this possible?
    Can someone advise on the best way to create indexes and search when a table schema such as the following exists. I've tried to keep it simple by just giving a few example columns and tables.
    Order Table
    - Has columns related to the order details - order name (varchar2), description (varchar2), date order placed (timestamp), date order completed (date), order amount (number), customer Id
    Customer Table
    - Has columns related to the customer information - customer name, address, city, state, telephone etc (all varchar2 fields)
    Items Table
    - Has details about the items being ordered - item name (varchar2), item description (varchar2), cost (number) etc
    Order-Item Table
    - Table that maps an order to the items in that order - orderId, itemId, quantity
    Comments Table
    - Logs any comments with the customer - comment description (varchar2), call type (varchar2), comment date (timestamp)
    Currently with the Context index, I have it set up so I can search all text columns in all tables for a search term. This works fine.
    I now need to be able to do more advanced searches, where I can search for a specific text in all orders as well as orders created after a certain date or orders above a certain amount or orders with a item quantity purchase of more that 10. The text has to be searched across the all text columns in all tables. How can I achieve this with Oracle Text?

    There was a similar discussion with various ideas that may help you here:
    How can I make CONTAINS query work for a date range

  • Index Multiple Column of Multiple Tables

    Hi All,
    I would like to know how to create a index which can search through all column in my database tables. Eg: I have 30
    tables and every tables have around 10 columns. I want to create a index which can search through the columns in
    these tables.
    I know that User_DataStore can helps in create multiple column search across multiple tables. But in my case the BLOB
    created will be very huge. Any work around? I mean is there any solutions like concatenated datastore?
    Thank You.
    Regards,
    LG Tan

    Hi,
    I figured out how to do this today. The first thing is that the type of index you need is a USER_DATASTORE.
    The idea behind this type of index is pretty straight forward but the documentation does a very good job of not drawing attention to just how powerful it is.
    The idea behind a USER_DATASTORE is that you can write your own stored procedure to extract the data that you want to index and return it to the indexer. Take an example where you have a master table which contains enough information to allow you to find associated data in other tables i.e. a shared key. The idea is that when you set up a USER_DATASTORE index, you specify the name of a stored procedure that the indexer will call for each row in the master table. The stored procedure has one input and one output parameter, rowid (in) and clob (out).
    When the index is created, the stored procedure you specify is, as I said above, called for each row in the master table. Your stored procedure uses this ROWID to extract the shared key (this can be anything you want) from the master table and uses this to build the necessary SELECT statement to retrieve the related data from the other tables. The rest of the stored procedure simply appends the data returned from your select statement to the return CLOB. The indexer then indexes the inforamation in this CLOB and discards the data.
    The index can of course only return hits against the master table. It's up to your application to extract shared key from the returned row(s), bind to the other tables and present the results.
    You will find a basic example of how to implement USER_DATASTORES in the Oracle Text Reference Guide (http://download.oracle.com/otndoc/oracle9i/901_doc/text.901/a90121.pdf). Feel free to email me if you want some example code.
    Dean

  • How to use a USER_DATASTORE to index multiple columns in different tables

    I would appreciate if somebody can give an example or point to links with examples on how to use USER_DATASTORE on multiple columns in different tables. THe Oracle Text documentation only shows multiple columns in the same table.
    Thanks in advance.

    I am not sure why your getting the wrong results but you should seriously reconsider the approach your are taking. Using functions like this is very ineffecient and should be avoided at all cost.

  • Selecting all columns makes oracle use more indexes than only selectng one?

    I have 3 queries here that differ only slightly, conceptually, but the plans are massively different. What I cant work out is that the difference is only in the select list.. The fields referenced in the where clause are properly indexed for this purpose
    SELECT
      scc.expiry_date
    FROM
      bw3.int_file_log_details  ifld
      INNER JOIN
      bw3.svc_card_status_change scsc
      USING
        (institution_number, file_number)
      INNER JOIN bw3.svc_client_cards scc
      USING
        (card_number)
    WHERE
      institution_number = '00000001' AND
      file_number = '00002504'This one above does a full table scan of SCC, over 3.5 million records
    SELECT
      card_number
    FROM
      bw3.int_file_log_details  ifld
      INNER JOIN
      bw3.svc_card_status_change scsc
      USING
        (institution_number, file_number)
      INNER JOIN bw3.svc_client_cards scc
      USING
        (card_number)
    WHERE
      institution_number = '00000001' AND
      file_number = '00002504'This one above does an index fast full scan of SCC's pk (which is cardnumber), as does doing a "SELECT null as dummy FROM..."
    SELECT
    FROM
      bw3.int_file_log_details  ifld
      INNER JOIN
      bw3.svc_card_status_change scsc
      USING
        (institution_number, file_number)
      INNER JOIN bw3.svc_client_cards scc
      USING
        (card_number)
    WHERE
      institution_number = '00000001' AND
      file_number = '00002504'This one above does the index range scan of the columns mentioned in the where clause and two index unique scans to link in IFLD and SCC (because they are joined on their PKs)
    I would expect all queries to run this way and completes in ~0.01 seconds
    Now, I get that oracle will sometimes use only an index instead of a table access when the requested data can be got from the index, but the actual query is pulling data from some columns not in indexes, so must be accessed in the table:
    SELECT
      scsc.card_prod_data as "Field1",
      substr(card_number,1,4)||' '||
        substr(card_number,5,4)||' '||
        substr(card_number,9,4)||' '||
        substr(card_number,13,4)||' '||
        substr(card_number,17) as "Field2",
      '                           ' as "Field3",
      scc.emboss_line_1 as "Field4",
      scc.emboss_line_2 as "Field5",
      TO_CHAR(TO_DATE(scc.last_issued_date, 'YYYYMMDD'), 'MM/YY ')||
        TO_CHAR(TO_DATE(scc.expiry_date, 'YYYYMMDD'), 'MM/YY  ')||
        '    ' as "Field6",
      'B'||
        card_number||
        '^'||
        RPAD('0', 27, ' ')||
        '^'||
        to_char(to_date(scc.expiry_date, 'YYYYMMDD'), 'YYMM')||
        service_category_code||
        '000000000000' as "Field7",
      card_number||
        '='||
        to_char(to_date(scc.expiry_date, 'YYYYMMDD'), 'YYMM')||
        service_category_code||
        '000000000000' as "Field8",
      card_number as "Field9",
      scsc.cvv_cvc2 as "Field10"
    FROM
      bw3.int_file_log_details  ifld
      INNER JOIN
      bw3.svc_card_status_change scsc
      USING
        (institution_number, file_number)
      INNER JOIN bw3.svc_client_cards scc
      USING
        (card_number)
    WHERE
      institution_number = '00000001' AND
      file_number = '00002504'This query above, which uses some data from all tables, does a table full scan of SCC, yet if I SELECT * FROM.. I get the expected index usage and table access by index rowid for all tables..
    Why is oracle doing an FTS when I choose only some columns, yet doing index access when I select * ?
    Edited by: charred on Oct 5, 2010 11:37 AM

    Selectivity of indexes?
    For a query linking these tables:
    int_file_log_details <-> svc_card_status_change <-> svc_client_cards
    I'm expecting Oracle to:
    Use an index range scan of the index on svc_card_status_change that is a nonunique index of institution_number and file number. Selectivity of this index is:
    1 institution number in the entire table
    59 distinct file numbers in the entire table
    4.1million records in the entire table
    From there, with the records it found, to use index unique scan of the PKs of int_file_log_details (file_number: 1 record required) and PK of svc_client_cards (card_number: poetntially thousands of records required)
    I can understand if oracle might decide it can get 69k records out of 4.1 million faster by FTS the cards table rather than having the indirection of the index... what I cannot understand is:
    If I select all the data from the query (SELECT *) it does unique index scans for the 2 records
    If I select say, only one non-indexed non-joined column from each table, oracle prefers a FTS of the cards table..
    Is oracle not realising that there are only 2 records I need out of cards? Why would select * differ? Is it that oracle thinks "select * is a large amount of data, so it'll be faster to use the index and target certain rows" vs "select one_column can be garnered more quickly by scanning the table and generating a lower overall memory load" ?

  • Help with creating oracle text index on 2 columns with partial html data

    Hi,
    I need to create an oracle text index on 2 columns.
    TITLE - varchar(255) = contains plain text data
    DESCRIPTION - CLOB = contains partial HTML data
    This is what I created.
    begin
    ctx_ddl.create_preference ('Title_Description_Pref', 'MULTI_COLUMN_DATASTORE');
    ctx_ddl.set_attribute('Title_Description_Pref', 'columns', 'TITLE, DESCRIPTION');
    end;
    begin
    ctx_ddl.create_preference ('bid_lexer', 'BASIC_LEXER');
    ctx_ddl.set_attribute('bid_lexer', 'index_stems', 'ENGLISH');
    ctx_ddl.create_section_group('htmgroup', 'HTML_SECTION_GROUP');
    end;
    create index Bid_Title_Index on Bid(title) indextype is ctxsys.context parameters ('LEXER bid_lexer sync (every "sysdate+(1/24)")');
    create index Bid_Title_Desc_Index on Bid(description) indextype is ctxsys.context parameters ('LEXER bid_lexer DATASTORE Title_Description_Pref sync (every "sysdate+(1/24)") filter ctxsys.null_filter section group htmgroup');
    The problem is when I do a CONTAINS(description, '$(auction)')>0. I get results where the descriptions have the "auction" word (which is correct). But, the results also returned rows where the search word is inside an IMG tag. e.g. <img src="http://auction.de/120483" alt="Auction Logo"/>.
    What I would like is to exclude rows where the search word is inside HTML tag attributes, results expected are rows having <a>Auction</a> or <p>For Auction</p> ... etc. Basically stripping the html tags and leave the text contents.
    I'd appreciate some input.
    Thanks,
    Amiel

    Hi,
    I need to create an oracle text index on 2 columns.
    TITLE - varchar(255) = contains plain text data
    DESCRIPTION - CLOB = contains partial HTML data
    This is what I created.
    begin
    ctx_ddl.create_preference ('Title_Description_Pref', 'MULTI_COLUMN_DATASTORE');
    ctx_ddl.set_attribute('Title_Description_Pref', 'columns', 'TITLE, DESCRIPTION');
    end;
    begin
    ctx_ddl.create_preference ('bid_lexer', 'BASIC_LEXER');
    ctx_ddl.set_attribute('bid_lexer', 'index_stems', 'ENGLISH');
    ctx_ddl.create_section_group('htmgroup', 'HTML_SECTION_GROUP');
    end;
    create index Bid_Title_Index on Bid(title) indextype is ctxsys.context parameters ('LEXER bid_lexer sync (every "sysdate+(1/24)")');
    create index Bid_Title_Desc_Index on Bid(description) indextype is ctxsys.context parameters ('LEXER bid_lexer DATASTORE Title_Description_Pref sync (every "sysdate+(1/24)") filter ctxsys.null_filter section group htmgroup');
    The problem is when I do a CONTAINS(description, '$(auction)')>0. I get results where the descriptions have the "auction" word (which is correct). But, the results also returned rows where the search word is inside an IMG tag. e.g. <img src="http://auction.de/120483" alt="Auction Logo"/>.
    What I would like is to exclude rows where the search word is inside HTML tag attributes, results expected are rows having <a>Auction</a> or <p>For Auction</p> ... etc. Basically stripping the html tags and leave the text contents.
    I'd appreciate some input.
    Thanks,
    Amiel

  • Indexing multiple columns of multiple tables

    Hi,
    I'm trying to index multiple columns of multiple tables.
    As I have seen, the way to do this is using User_Datastore.
    have the tables to share a (foreign)key? My tables have only 2 or 3 similar columns(description, tagnr...)
    I want to get the different tagnr belonging to the same description etc.
    Can I do this?
    Has anyone a Samplecode indexing multiple tables?
    Any suggestion would be helpful.
    Arsineh

    A USER_DATASTORE works like this:
    create table A
    ( id number primary key,
    textA varchar2(100));
    create table B
    ( id number primary key,
    textB varchar2(100));
    procedure foo (rid in rowid, v_document in out varchar2)
    v_textA varchar2(2000);
    v_idA number;
    v_textB varchar2(2000);
    begin
    select id, textA
    into v_idA, v_textA
    from A
    where rowid = rid;
    select textB
    into v_textB
    from B
    where id = v_idA;
    v_document := textA &#0124; &#0124; ' ' &#0124; &#0124; textB;
    end;
    create preferences for USER_DATASTORE
    create index ...
    on table A ( text) ...
    you also can build on table B
    This depends where you want the
    trigger to be build to sync the
    documents.
    null

  • Primary Key Multiple Column with Date - parameter issue

    All,
    I am having an issue that I cannot find the answer to. I have looked high and low to no avail. Please help.
    The issue at hand is that I have a table that has a multiple column primary key and one of the columns happens to be a date and the other is a string. I have a basic search and I want an update picture in the results table that the users can click on and go to a different page to update that record. The issue is when I fire an action based on the update picture I also want to set parameters based on the record that I selected. So I set the string parameter and that works fine. The issue is with the date. When i set the date parameter it works but it chops off the timestamp. Later when I try to get this parameter 'pageContext.getParameter("dateParameter");' it will bring in a date like 15-Dec-2008 but I need the entire date and timestamp (i.e. 15-Dec-2008 10:20:33) to correctly identify the record.
    Please help!
    Thanks,
    Colby J

    Hi
    since every parameter go in url as a string format so u will never get the date parameter with complete timestamp,the solution would de
    1.) Set a fire action on update picture,give its event name as "update",
    2.) clicking on update picture will fire this event .
    3.) in processFormrequest method of controller
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    if ("update".equals(pageContext.getParameter("event")))
    // this will give the select row where update is clicked
    String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
    VORowImpl row = (EmployeeSummaryVORowImpl)am.findRowByRef(rowReference);
    Timestamp sdateVal=(String)row.getAttribute("Date value");
    // this will transfer the values to next page
    pageContext.putTransactionTransientValue("transferdvalue",sdateVal);
    // and in the next page u can get the value like this
    timestamp getDateVal=pageContext.getTransactionTransientValue("transferdvalue"l);
    hope this will resolve your issue,Please let me know if u face any issue
    thanx
    Pratap

  • The issue with using the multiple columns sub-query in WHERE clause

    Hi All,
    my database version is 10.2.
    the problem i am trying to deal with is that when I use multiple column sub-query in the WHERE clause of the SELECT statement, the actual row number returned from the sub-query is different from the whole statement.
    And what I found is that, whenever there is NULL in any of those columns returned from the SUB-QUERY, the outer query will just return NULL for that whole row.
    Here is an example:
    select empno, ename, job, mgr, hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  mgr, hiredate, sal, deptno from t;
    7782     CLARK     MANAGER     7839     09-JUN-81     2450     10
    7839     KING     PRESIDENT  NULL  17-NOV-81     5000     10
    7934     MILLER     CLERK     7782     23-JAN-82     1300     10
    select * from EMP where (EMPNO, ENAME, job, MGR, HIREDATE, SAL, DEPTNO) in (
    select empno, ename, job, mgr, hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  mgr, hiredate, sal, deptno from t);
    7782     CLARK     MANAGER     7839     09-JUN-81     2450          10     
    7934     MILLER     CLERK     7782     23-JAN-82     1300          10     If I specifically deal with the NULL situations for the columns which might return NULL, I can get the result right.
    select * from EMP where (EMPNO, ENAME, job, NVL(MGR,-1), HIREDATE, SAL, DEPTNO) in (
    select empno, ename, job, nvl(mgr,-1), hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  nvl(mgr,-1), hiredate, sal, deptno from t);
    7782     CLARK     MANAGER     7839     09-JUN-81     2450          10     
    7839     KING     PRESIDENT  null   17-NOV-81     5000          10     
    7934     MILLER     CLERK     7782     23-JAN-82     1300          10     the problem is that, I feel this is a very lame way of handling it.
    So, I wonder or am asking if there is any better or standard way to do it?
    any help would be highly appreciated.
    Thanks

    Hi,
    As you discovered, INTERSECT treats NULL as a value, but IN does not.
    What you did with NVL is one way to handle the situation. If there was a chance that any of the columns could be NULL, then you might prefer something like this:
    select      *
    from      EMP
    where      ( EMPNO      || '~' ||
           ENAME      || '~' ||
           job           || '~' ||
           MGR           || '~' ||
           TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')
                    || '~' ||
           SAL           || '~' ||
           DEPTNO
         ) in (
              select  EMPNO      || '~' ||
                     ENAME      || '~' ||
                   job     || '~' ||
                   MGR     || '~' ||
                   TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')               
                        || '~' ||
                   SAL      || '~' ||
                   DEPTNO
              from     emp
             intersect
              select  EMPNO      || '~' ||
                     ENAME      || '~' ||
                   job     || '~' ||
                   MGR     || '~' ||
                   TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')               
                        || '~' ||
                   SAL      || '~' ||
                   DEPTNO
              from      t
             );This assumes that you can identify some string (I used '~') that never occurs in the strings in these tables.
    This is implicitly converting the NUMBERs. That's usually not a good thing to do. but explicitly converting them would make this even more tedious.
    You should explicitly convert any DATEs to strings, however. Depending on your default format, and your data, you might get away with implicit conversions even for DATEs, but don't bet on it.
    If you had to do this often, you might consider writing a user-defined function:
    delimited_string (empno, ename, job, mgr, hiredate, sal, deptno) would return a string like
    '7839~KING~PRESIDENT~~17-NOV-1981~5000~10'
    This will make the coding easier, but beware: it will make the execution slower.

  • Do ORACLE support indexing on the columns with Hebrew Data

    Hello Forum,
    I was working on an assignment with schemas containing Hebrew Data.
    Can i create indexes on the columns containing Hebrew Language data?
    Thanks
    Priyank Jain

    Varchar2; is something difficult for me. Reason why is I need to make change in my application throughout to accept this design change.
    My need of Index on Hebrew Data:
    Basically I am going to implement a Full-Text Search environment. For full-text searching; I am having a plugin which implements Lucene Algorithm of Indexing.
    The Index writing will not be useful until the table is indexed and well-functional.
    "But note that standard indexes will be sorted according to binary order of Hebrew letters in Unicode."
    So does it means we are not going to index on actual data (Data in Hebrew)??
    Thanks
    Priyank Jain

Maybe you are looking for