unique index for several columns

Hi all

We have a requirement for our application, to add a single search box, which searches more than 1 table of different columns. The way in which we have now implemented, is the following (simplified example):
Select *.
WCP
where instr(ename,:SEARCH) > 0
or instr(job,:SEARCH) > 0
or...

This approach is relatively slow, of course. I want to change it, using the text of the Oracle. Can you give me advice what kind of index, must be used? Our requirement:
-index must continue to be up-to-date (a few seconds)
-research must be
-case insensitive preference
-number of columns to be indexed: aprox. 20 in a table

I heard once you can make a function, with all the columns you want to index. This function generates an xml document, and you can use this function to create an Oracle text index. However, I can't seem to find how I can implement that. Or is there a better aproach?

Thanks again for your help!

You can use a multi_column_datastore, that generates xml documents as you describe in the scenes. You can also use the transactional option or sync (on validation) with optimization. See the simplified example with only two columns below that matches what you provided. You can find further information and examples for the multi_column_datastore in the online documentation.

SCOTT@orcl_11gR2> begin
  2    ctx_ddl.create_preference ('emp_ds', 'multi_column_datastore');
  3    ctx_ddl.set_attribute ('emp_ds', 'columns', 'ename, job');
  4  end;
  5  /

PL/SQL procedure successfully completed.

SCOTT@orcl_11gR2> alter table emp add (any_column varchar2(1))
  2  /

Table altered.

SCOTT@orcl_11gR2> create index emp_idx
  2  on emp (any_column)
  3  indextype is ctxsys.context
  4  parameters
  5    ('datastore emp_ds
  6        transactional')
  7  /

Index created.

SCOTT@orcl_11gR2> variable search varchar2(100)
SCOTT@orcl_11gR2> exec :search := 'CLARK'

PL/SQL procedure successfully completed.

SCOTT@orcl_11gR2> select ename, job from emp
  2  where  contains (any_column, :search) > 0
  3  /

ENAME      JOB
---------- ---------
CLARK      MANAGER

1 row selected.

SCOTT@orcl_11gR2> exec :search := 'CLERK'

PL/SQL procedure successfully completed.

SCOTT@orcl_11gR2> select ename, job from emp
  2  where  contains (any_column, :search) > 0
  3  /

ENAME      JOB
---------- ---------
SMITH      CLERK
ADAMS      CLERK
JAMES      CLERK
MILLER     CLERK

4 rows selected.

Tags: Database

Similar Questions

  • Unique index on two columns based on the conditon

    I have a table where I have two columns name and feed.
    create table test1 (name varchar(20), feed varchar(4));
    
    insert into test1 values('abc','L3');
    insert into test1 values( 'abc','Both');
    insert into test1 values('abc','L2');
    I want to create a unique index for the lines abc - L3 and cant abc - both together be inserted, rest the other flow values is not a problem, so the first two rows can not be there in the table.

    Please suggest

    Thajs
    create unique index test1_ind1 on test1 (name, case when feed = 'Both' then 'L3' else feed end );
    

    Who did what you asked...

    However, I highly doubt it does what you WANT.

    Please provide information on the requirements, and we the flesh that out a little better.

  • When we use a unique index for PK?

    I was reading this part of the manual oracle:

    http://docs.Oracle.com/CD/B28359_01/server.111/b28310/indexes003.htm#ADMIN11727

    I got confused because I was trying to research why sometimes, we want to create a primary key by using a unique index.

    CREATE A UNIQUE MYTABLE_PK ON MYTABLE INDEX

    (START_DT, ANNUAL)

    LOGGING

    TABLESPACE TBS_INDEX01

    NOPARALLEL;

    ALTER TABLE MYTABLE ADD)

    CONSTRAINT MYTABLE_PK

    KEY ELEMENTARY SCHOOL

    (START_DT, ANNUAL)

    WITH THE HELP OF INDEX MYTABLE_PK);

    And sometimes we simply create the primary key without using a unique index.

    ALTER TABLE MYTABLE ADD)

    CONSTRAINT PK_MYTABLE

    KEY ELEMENTARY SCHOOL

    (START_DT, ANNUAL)

    THE HELP INDEX);

    When we use a unique index for PK?

    James, you have returned to the question thread.

    I apologize: I'm sorry, user8875620, your son has been hijacked. A UK or PK constraint needs an index. You can create a (unique or non-unique) explicitly, or you can let Uncle Oracle create it implicitly when you define the constraint.

  • unique index on two columns

    Hi all
    I want a unique index on two columns, but when I try this it will show me
      1  CREATE UNIQUE INDEX sale_order_no
      2*   ON sale_order (sale_order_no, season_year)
    SQL> /
      ON sale_order (sale_order_no, season_year)
         *
    ERROR at line 2:
    ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found
    I want to do not overlap with the combination of these two

    Plaese Guide
    Thanks and greetings
    Vikas

    You would this behavior if SALE_ORDER_NO has NULL values. If it contains NULL values, a unique single-column index will succeed but an index unique multi-column will fail when it finds duplicates in SEASON_YEAR.

    See:

    SQL> create table dummy_objects (object_id  number, object_owner varchar2(30), object_name varchar2(30));
    
    Table created.
    
    SQL> insert into dummy_objects values (0,'HEMANT','TABLE_A');
    
    1 row created.
    
    SQL> insert into dummy_objects values (1,'HEMANT','TABLE_B');
    
    1 row created.
    
    SQL> insert into dummy_objects values (NULL,'HEMANT','NULL_1');
    
    1 row created.
    
    SQL> insert into dummy_objects values (NULL,'HEMANT','NULL_2');
    
    1 row created.
    
    SQL> create unique index dummy_objects_u1 on dummy_objects(object_id);
    
    Index created.
    
    SQL> drop index dummy_objects_u1;
    
    Index dropped.
    
    SQL> create unique index dummy_objects_u2 on dummy_objects(object_id, object_owner);
    create unique index dummy_objects_u2 on dummy_objects(object_id, object_owner)
                                            *
    ERROR at line 1:
    ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found
    
    SQL>
    

    Hemant K Collette
    http://hemantoracledba.blogspot.com

  • You need to install unique app for several identifiers without user intervention to make a first time sign in.  Can we encrypt the connection information in the installation

    In the old days of Volume License, we have just script the installation with a unique license for CLP licenses key.  Now, we have a different package for each simple installation with a different login id.  What happens if you make 10 or 100 with several identifiers

    Move this discussion to the enterprise deployment for Creative Cloud, forum of Creative Suite.

  • How to get the checksum for several columns?

    I need to compare the data of a record in a data table in another table. The structures of the two tables are not the same, but the data types of the columns I'm comparing cam is obviously the same. There are many columns so I thought that a shortcut to make a crazy long A = A AND B = B, etc... several dozens of times to check if the data are different each time was to use checksum.

    I had planned to use the concatenation of all the columns together in a single string, delmitted by a semicolon.

    However, I find that it does not work as desired. The checksum produces the same number for different values of data. So I need ot use something else.

    There is another function I could use in a similar way where it will create a compact, unique hash to a concatenated string of time I spend?

    And what is the data type of the return value - hoping that it's digital!

    What checksum algorithm do you use?

    Depending on the version of Oracle, you can use the HASH of the package DBMS_CRYPTO method, i.e.

    SELECT dbms_crypto.hash( to_clob( ename || empno || sal ),
                           1 /* dbms_crypto.hash_md4 */ )
      FROM emp
    

    A MD4 hash should have a very low incidence of collisions of normal data even if it isn't particularly cryptographically course. You can also use the ORA_HASH method

    SELECT ora_hash( ename || empno || sal )
      FROM emp
    

    but I expect the chance of collisions to be a little higher.

    Justin

  • Spatial index error while creating an index for a column GeoRaster

    Hi all

    Several months ago, I inserted 12 map PNG Raster files in Oracle as GeoRaster data. I then looked into MapBuilder to verify that they have been charged, and as they appear, it seems to suggest that they were.

    Today, however, I realized that I had not created an entry for USER_SDO_GEOM_METADATA or a spatial index. That's why I tried to do it by using the code below. When I made an entry in USER_SDO_GEOM_METADATA, I didn't add .spatialextent after the column name, web_raster_map. But while reading the manual MapViewer I decided that it was necessary to create a new entry. However, the error message displayed at the end, was the same in each case. If anyone has any ideas on what I can hurt, I would be grateful.

    Is the entries abscissa-x and the ordered is wrong? Should this be X and Y, and if that resolves the errors? I've been using a script I created previously to vector data and adapting.
    INSERT INTO USER_SDO_GEOM_METADATA
    (TABLE_NAME,
    COLUMN_NAME,
    DIMINFO,
    SRID)
    VALUES (
    'WEB_RASTER_MAP_FILE',
    'web_raster_map.spatialextent',
    SDO_DIM_ARRAY( -- full grid size goes here
    SDO_DIM_ELEMENT('eastings-x', -3273.58473839662, -8471.66, 0.005),
    SDO_DIM_ELEMENT('northings-y', -9694.76, -1632.88473839662, 0.005)),
    96163497); -- this is a user created srid
    commit;
    
    CREATE INDEX WEB_RASTER_MAP_FILE_IDX ON WEB_RASTER_MAP_FILE (web_raster_map)
       INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    commit;
    Error message was:
    Error starting at line 14 in command:
    CREATE INDEX WEB_RASTER_MAP_FILE_IDX ON WEB_RASTER_MAP_FILE (web_raster_map)
       INDEXTYPE IS MDSYS.SPATIAL_INDEX
    Error at Command Line:14 Column:13
    Error report:
    SQL Error: ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13200: internal error [Unsupported Type] in spatial indexing.
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 10
    29855. 00000 -  "error occurred in the execution of ODCIINDEXCREATE routine"
    *Cause:    Failed to successfully execute the ODCIIndexCreate routine.
    *Action:   Check to see if the routine has been coded correctly.
    commit succeeded.
    Kind regards

    Tim

    Published by: user467357 on March 23, 2009 17:45
    To add an additional comment.

    Tim,
    You must create the index on web_raster_map.spatialextent.
    The create index must therefore:

    CREATE the INDEX WEB_RASTER_MAP_FILE_IDX ON WEB_RASTER_MAP_FILE (web_raster_map.spatial_extent)
    INDEXTYPE IS MDSYS. SPATIAL_INDEX;

  • Unique table with several columns or several tables split?

    What is the best.

    A table with multiple columns inside or divided into several tables. Why?
    How will the performance in the two scenarios?

    Hello

    user13024762 wrote:
    I have a table EMP that has column EMP_ID, EMP_NAME MGR_ID, MGR_NAME, SALARY, EXP_IN_MNTHS, EXP_IN_YRS... etc with multiple columns

    I have the following tables
    EMP-> EMP_ID, EMP_NAME

    Each row in the table emp thie represents a separate employee. I guess other columns in the emp table might be birth_date, social_security_number and status (by example, 'Active', 'Leave', 'complete'). Here's what an employee has (at least) one of. If there is a one-to-many relationship between an employee and an attribute, then you probably want another table for this attribute.

    BISHOP-> EMP_ID, MGR_ID, MGR_NAME

    There is a one-to-many relationship between employees and managers? In other words, an employee may have 2 or more managers? If Yes, then you need another table.
    If there is only a one-to-one relationship between employees and managers (in other words, if an employee is never more than 1 Manager) so why don't you just have a mgr_id column in the emp table?
    Managers are also used for? (This is often the case, as in scott.emp and hr.employees.) If so, do not store their names in the EME and tables of mgr. Store name (and date of birth and other information) in the table emp only and, if you need a table of Bishop, just the emp_id and mgr_id column.

    SAL-> EMP_ID, SALARY

    There is a one-to-many relationship between the employees and wages? In other words, an employee may have 2 or more treatments? If so, how will you use the values? Is a special treatments in some way, as it will be used more often than others? (In other words, you may have a current and past wages salary, but the last wages are rarely used.)
    If you never have more than 1 salary for a given employee, why not just have a sal column in the emp table?

    EXP-> EMP_ID, EXP_IN_MNTHS, EXP_IN_YRS

    There is a one-to-many relationship between the employees and what whether you store in this table?

    etc. with more tables

    What is the best based on

    (1) performance and data recovery
    (2) ease of use
    (3) maintainability

    A one-to-many relationship requires an additional table. If an employee can have up to 3 managers, don't have mgr1, mgr2 and mgr3 columns in the emp table. Use a separate table, with up to 3 lines for the same employee, instead.
    For 1-1 relationships, it is usually best to not have separate tables.

  • Unique event for several dynamic buttons

    I want to use a function of earphone unique event to manage several dynamically created movie clips, each movie clip triggering a different answer. I am pulling information from an xml file, which will in turn create x video clips for the information found. Each video clip would be clickable, and each would have a unique result. Sake of argument: each created movie clip dynamically would trace his name when you click on it.

    Download

    demoX.addEventListener (MouseEvent.CLICK, traceName);
    demoY.addEventListener (MouseEvent.CLICK, traceName);
    demoZ.addEventListener (MouseEvent.CLICK, traceName);
    {traceName (event:MouseEvent)}
    trace (/ *? * /); meet "demoX" or "James" or "amel" respectfully
    }

    I guess I need to create my clip dynamically and then dynamically create an event listener for it. But then I don't know how I would have access to information that the user has clicked. I could be away from the base. I did this sort of thing with AS2 (and maybe my method was not quite at the level of standards,) but I can of course find a way to do this in AS3. Any help would be appreciated.

    Thank you!

    the event.currentTarget will return the released movieclip. You can add any property/value you want (for example, a name property) your movieclip buttons. This property is accessible via event.currentTarget.yourProperty (for example, event.currentTarget.name) in traceName().

  • cases when for several columns

    Hello, Experts

    Could help me please on the function below. ?

    How to call two different columns in the instruction box.

    I'm migrating some of the BO decode OBIEE11g reports to help can we able to reach below senario in BO-universe but I don't know how we can achieve this in RPD - OBIEE 11 g

    DECODE (TABLE.NAME_1. Column_name, 'Client Meeting passwords', TABLE_NAME2. COLUMN, NULL)

    Concerning

    Sri

    Thanks for the reply Ceresa... !

    I use Case when statement... but I could not able to include more than one Table_Name.Coulmn_Name. the RPD

    For Ex in BO_Universe, it's logic has been used: DECODE (RPT.CUST_INFO.INFO_SUBTYPE,'Customer has past, RPT.) CUST_INFO. BODY, NULL)

    OBIEE: I'm trying to use like this: case when RPT.CUST_INFO.INFO_SUBTYPE,'Customer has past AND the RPT words. CUST_INFO. BODY = "NULL") END.

    ERROR: [nQSError: 27002] near <=>: syntax error [nQSError: 26012].

    Please guide me I missed something in the formula... ?

    I thank in advance. !

    Sri

  • Unique Taskflow for several regions of the

    Hi all

    I wonder if it's possible. Let me explain the scenario:

    I have a menu with 4 gomenuitems and a taskflow with view 4 activities.
    When you click on an element of firstmenu I want the first activity of view which will be called and displayed as a region and vice versa
    This can be using the dynamic and vibrant region link concept, but in this case, I must have 4 taskflows
    but v run this unique taskflow scenario.

    Hope it is clear...

    Thank you

    Hello

    the views are in a stream unique task, is it the default activity is an activity of router. Then go viewId name you want to see as an entry for the workflow setting and make sure that the area is refreshed (you can set Refresh on IfNeeded region for triggers to change value of input parameter of task flow cooling in response to a partial refresh--> PartialTriggers property on af:region pointing to your menu item ID). The router accesses the value of input parameter and determines the case of control flow to the view in the region

    Frank

  • Using the account with pivot for several columns

    create table TEST_CASETBL (ID, NUM, TYPE, CREATED_BY, CREATED_DT) that choose

    1, 1-1, CO, ABC, sysdate-10 of all the DOUBLE select union

    2, 1-1, EO, ABC, sysdate-10 of all the DOUBLE select union

    3, 1-2, CO, ABC, sysdate-10 of all the DOUBLE select union

    4, 1-2, UPD, ABC, sysdate-10 of all the DOUBLE select union

    5, 1-3, CO, XYZ, sysdate-10 of all the DOUBLE select union

    6, 1-3, EO, XYZ, sysdate-10 of all the DOUBLE select union

    7, 1-4, CO, XYZ, sysdate-10 of all the DOUBLE select union

    8, 1-4, NT, XYZ, sysdate-10 of all the DOUBLE select union

    9, 1-5, EO, XYZ, sysdate-10 of all the DOUBLE select union

    10, 1-5, NT, XYZ, 10 sysdate from DUAL;

    I want to calculate number of NUM, County of different values in the 'TYPE' column based on the CREATED_BY column

    Expected result:

    CREATED_BY Count (NUM) Count (CO) Count (EO) Count (s) Count (UPD)

    ABC                                 2(which means 1-1,1-2)               2                   1                         0            1

    XYZ                           3(which means 1-3,1-4,1-5)               2                    2                        2            0

    Please provide your suggestions to solve the SQL query form

    Thank you

    Hello

    Melissacharlier-Oracle wrote:

    create table TEST_CASETBL (ID, NUM, TYPE, CREATED_BY, CREATED_DT) that choose

    1, 1-1, CO, ABC, sysdate-10 of all the DOUBLE select union

    2, 1-1, EO, ABC, sysdate-10 of all the DOUBLE select union

    3, 1-2, CO, ABC, sysdate-10 of all the DOUBLE select union

    4, 1-2, UPD, ABC, sysdate-10 of all the DOUBLE select union

    5, 1-3, CO, XYZ, sysdate-10 of all the DOUBLE select union

    6, 1-3, EO, XYZ, sysdate-10 of all the DOUBLE select union

    7, 1-4, CO, XYZ, sysdate-10 of all the DOUBLE select union

    8, 1-4, NT, XYZ, sysdate-10 of all the DOUBLE select union

    9, 1-5, EO, XYZ, sysdate-10 of all the DOUBLE select union

    10, 1-5, NT, XYZ, 10 sysdate from DUAL;

    I want to calculate number of NUM, County of different values in the 'TYPE' column based on the CREATED_BY column

    Expected result:

    CREATED_BY Count (NUM) Count (CO) Count (EO) Count (s) Count (UPD)

    ABC                                 2(which means 1-1,1-2)               2                   1                         0            1

    XYZ                           3(which means 1-3,1-4,1-5)               2                    2                        2            0

    Please provide your suggestions to solve the SQL query form

    Thank you

    This CREATE TABLE statement works when try you it?  Do you need single quotes around string literals?

    You may want something like:

    WITH data_to_pivot AS

    (

    SELECT created_by, type

    COUNT (DISTINCT num) over (PARTITION BY created_by) AS count_num

    OF test_casetbl

    )

    SELECT *.

    OF data_to_pivot

    PIVOT (COUNT (*)

    TO indicate the ("CO" AS count_co

    'EO' AS count_eo

    'NT' AS count_nt

    'UPD' AS count_upd

    )

    )

    ORDER BY created_by

    ;

  • R12 - how to generate a unique Journal for several bills entry

    Hello

    We observed that in R12, when newspapers are transferred to GL SLA, separate Journal header is created for each invoice AP. This will affect huge negative performance on our existing custom programs.

    What we want is when we transfer reviews from AP to GL at end of day every day, so don't that a single Journal Header(like in 11i) generate for all bills.

    In addition, what we have observed is by default the name of the Journal header is in the following format

    "AE_HEADER_ID +" "+ purchase invoices + ' ' + SOBCurreny.

    Example of log name is «5250003 purchase invoices USD»

    We are not sure weather that a separate Journal header is created due to the default of naming convenstion. Is what is happening because, by default, the AE_HEADER_ID is in the name of the header of the Journal? If we modify the subledger accounting method and remove the AE_HEADER_ID the name of the entry of newspaper Oracle generates a signle Journal entry on all invoices?

    Please let me know if anyone has an idea on how to achieve this.


    Thank you
    Lokesh.

    In my view, the patch 8846459 solve the problem.
    Please cross check.

    By
    VAMSi

  • How to get a separate account of several columns

    I've done this before and I'll darn why I don't remember this.

    A table with 3 columns with the primary key defined in the column.

    Line a, b and c
    NUM.
    1 020 how abc
    2 why 030 def
    3 010 no IGS
    4 how 040 abc
    Yes def 5 050
    6 060 why def

    So what I want is a number of unique values to columns b and c as if b and c were in fact a field.

    So the result of the query:
    Count = 4 unique lines.

    I hope I make some kind of sense. It is a bit much to know if the number of occurrences of each duplicate value, I know not just get the number of unique lines of lines not indexed will be enough. Because the query is supposed to be universal for several digital and alphanumeric data columns and can be extended for several columns, I'm just trying to get a basic skeleton which works for an analysis "on the fly".

    It will be useful.

    SQL>create table rb as select rownum A, rownum b , rownum c from dual connect by level < 11;
    
    Table created.
    
    Elapsed: 00:00:00.31
    SQL>select count(distinct a) from Rb
      2  union all
      3  select count(distinct B ) from Rb
      4  union all
      5  select count(distinct c) from Rb
      6  /
    
    COUNT(DISTINCTA)
    ----------------
                  10
                  10
                  10
    
    Elapsed: 00:00:00.53
    SQL>update rb set b = 3 where B > 5;
    
    5 rows updated.
    
    Elapsed: 00:00:00.26
    SQL>commit;
    
    Commit complete.
    
    Elapsed: 00:00:00.26
    SQL>select count(distinct a) from Rb
      2   union all
      3   select count(distinct B ) from Rb
      4   union all
      5   select count(distinct c) from Rb
      6   /
    
    COUNT(DISTINCTA)
    ----------------
                  10
                   5
                  10
    
    Elapsed: 00:00:00.53
    SQL>
    
  • creating a unique index of instaed of using the primary key index

    Hello

    I heard in a debate sometimes it is better to create a unique index on a column and use it instead of using the primary key index in oracle. I did not understand what that the reason propely.

    Can someone please help me in this topic if it is valid.

    Thanks in advance

    On the surface, which does not seem reasonable... Volume of the DML is irrelevent to determine which column is the primary key for a table.

    My wild speculation a bit at a reasonable time could someone do...

    If you use synthetic primary keys (i.e. the keys generated by sequence) and that your tables are subject to large volumes of inserts such as there is a danger that the block "to the right" will be the source of contention block and worry not about analysis of beach on the column, you can create a reverse on this column (unique or non-unique) key index before creating the primary key constraint and to indicate Oracle to use this existing index to respect the primary key constraint.

    Obviously, however, this involves a lot of assumptions to arrive at a reasonable point. There may well be another set of assumptions that could also lead to a valid argument. Or it could be a myth that someone has heard and just repeats.

    Justin

Maybe you are looking for