UNIQUE INDEX

CREATE TABLE IMP_HAND
(

LOAD_TIME DATE NOT NULL,
KVN_SEQ NUMBER (10) NOT NULL,
CREATIONDATE DATE NOT NULL
)

Examples of data
-----------------------------------------------------------------
"|" delimiter of data



LOAD_TIME | KVN_SEQ | CREATIONDATE
-------------------------------------------------------------
2011-03-07 17:12:33 | 15. 2011-03-08 17:12:33
2011-03-07 18:12:33 | 15. 2011-03-08 17:12:33
2011-03-07 19:12:33 | 15. 2011-03-08 17:12:33
2011-03-07 19:17:39 | 15. 2011-03-08 17:12:33
2011-03-07 19:52:51 | 15. 2011-03-08 17:12:33


How can I create a unique index on the column LOAD_TIME, KVN_SEQ on the IMP_HAND table

Hello

Search "CREATE INDEX" in the manual of the SQL language:
http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/clauses002.htm#i1034458
It has examples and explanations.

You must create a unique constraint , which automatically creates a unique index.
"CONSTRAINTS" are also in the manual of the SQL language.

Tags: Database

Similar Questions

  • What is the difference between primary key and unique indexes with forced not null?

    Primary key is = unique index + not null?

    The short answer is Yes.

    However, even if the primary key, applying both uniquness and not null, there is a notion of "special".

    You can only have one primary key in tables, but you can have multiple unique indexes and constraints not null.

    See: https://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:8743855576462

  • How to find duplicate keys found when error ORA-01452: cannot CREATE a UNIQUE INDEX.

    Hi gurus,

    I fall for this stupid error

    "cannot CREATE a UNIQUE INDEX; duplicate keys found.


    It is that the Unique Index key is composed of multiple columns

    CREATE A UNIQUE KEY001AUTORISATIONS_APPORT ON TFT_AUTORISATIONS_APPORT INDEX

    (AUT_APPORTEUR, AUT_AGENCE, AUT_PRODUIT, AUT_OPTION, AUT_TARIF, AUT_DATE_AUTORISATION)

    TABLESPACE KEYS_TFT NOPARALLEL NOLOGGING

    Now,.

    My question is, how to find duplicates keys blocking Index creation?

    Thanks if you can help

    Run this query to display the list of the duplicates already existing.

    Select AUT_APPORTEUR, AUT_AGENCE, AUT_PRODUIT, AUT_OPTION, AUT_TARIF, AUT_DATE_AUTORISATION, count (1) as cnt

    of TFT_AUTORISATIONS_APPORT

    Group

    AUT_APPORTEUR, AUT_AGENCE, AUT_PRODUIT, AUT_OPTION, AUT_TARIF, AUT_DATE_AUTORISATION

    view count (1) > 1

    Concerning

    NJ

  • When I change a column is a primary key the associated non-unique index to become unique?

    So basically I already tried this and it shows me that the associated index is not unique.

    create table employees2 in select * from employees;

    create index emp_idx on employees2 (employee_id);

    ALTER employees2 table add primary key (employe_id) using index emp_idx;

    Select * from user_indexes where index-name = "EMP_IDX";

    I was wondering if I right assuming that when you change a column to a primary key or unique while using a given index that does not have the respective index become unique.

    The textbooks I use are sometimes a little hard to understand because of the wording, also, I want to just ask someone with a little more experience than me.

    Thank you.

    your test did give the correct answer: the index is not unique if it serves to bear a unique or primary key constraint. Indeed, it is one of the benefits of the use of no unique indexes in support of UK/PK constraints (since it allows to set the unusable index before to make bulk loads; and, of course, they have also some disadvantages - for example, they need an additional logical reading to reach a line). Richard Foote explains the details in https://richardfoote.wordpress.com/2008/06/04/primary-keys-and-non-unique-indexes-whats-really-happening/ (and other items).

  • How to find the unique index to break the record?

    Hello

    When I do an UPDATE on a table how can I accumulate documents violates a unique index on the table? Is there something like "EXCEPTIONS IN" when using ALTER TABLE MODIFY CONSTRAINT... ENABLE VALIDATE EXCEPTIONS IN...?

    Oracle DB 10g

    Look in the logging of DML errors

    ORACLE-BASE - DML Oracle 10 g Release 2 of the database connection error

  • Duplicate display of unique indexes on diagram - how to remove?

    Hey people,

    A little new for the Modeler and I have a problem with a table I did where a unique index appears twice on my diagram.  I can't understand how to remove it.

    Any ideas?

    Thanks for the help!

    Eric

    In fact you need to look at the bitty little next to each icon and you will see that they are different. What you have is a unique index and a unique key constraint. Different objects in the database named but identical by the Data Modeler (which is automatically generated index when you declared the constraint). If you go to the properties of the table and click on the index node you will see. Now, click on the single key node and you will see the same name. Right-click on the table in the diagram and choose the DOF preview. After the create table code, you should see a create index command and create a unique alter constraint table.

    Why do you need both - constraint and different index information give the optimizer. You can do without one or the other - maybe. Tom Kyte wrote a note on this subject a while back on AskTom. If you're really curious, go here (I don't remember the details).

  • Unique and non-unique indexes


    Hello

    I have a unique index associated with no doubt. Unique and not unique indexes are used B tree architecture. But I want to know if I create a non-unique index on a column that contains unique data.

    When I query this table using this column, it scans each sheet or times found that value it scan stops and give us the result?

    00125 wrote:

    In a non-unique index, scans all the leaves... so what's the difference between full table scan and index ull. I went through a few articles they mentioned that a non-unique index to check with rowid. How she treated? I have clear knowledge in it.

    Please help me with this.

    Thanks in advance

    If you go through architecture index B-tree you could easily understand how indexing works. The picture here shows how a look of column datatype NUMBER indexed as / stored internally. You can imagine that your indexed column TST_COLA this will look like in the internal process. In the B-tree indexes, you have 3 main structures 1. 2 root. Branch 3. Leaves and the database retrieves lines by browsing through the root of index-> branch-> leaves. If the photo if we wanted to retrieve the row whose value indexed column = 25. First data goes to the root and finds that plugs is set to 25, then he Stoops to this particular branch of find what block sheet retains the value 25. More far away after finding the leaves block then goes to this block of sheets and research the special value of 25.

    If the index is UNIQUE, the database knows that there must be only one value, where it performs INDEX UNIQUE SCAN. If the index is NOT UNIQUE it should check all values in this block of leaves to find who all are 25 - in this case INDEX RANGE SCAN is done - as you must check not only value, but all values in this block of sheets - given that the values are not unique. As you can see it that the sheet block contains the long side of the value of the column ROWID, using this database rowid, then goes to the table to retrieve that particular line.

    Full table scan is a method of access where the database just to access the table directly (bypassing index structure) and analyze the ENTIRE table to satisfy the request.

  • Transform a no Unique Index in a single index

    Hello

    Version: 11.2.0.4.0 Enterprise Edition

    We got a non-unique Index for a primary key constraint. I would like to change that in a unique index. I know that you can not change the index to change. Is the only way to disable the primary key, delete the index and re-enable the constraint or is there a better solution? It is a 24/7 platform.

    sql_colder

    Windows service exist for a reason.

    You can also create clues online in an operational database.

    There is no other method outside the use of DBMS_REDEFINITION.

    Think about it: what is the business case to change the index?

    -----------

    Sybrand Bakker

    Senior Oracle DBA

  • Unique index constraint Vs Unique

    Dear all,

    I just want to understand what is the difference between a Unique Index and uniqueness constraint

    I can create indexes like that, it duplicates will be blocked

    create table abhi_1 
    ( l_number number 
    )
    CREATE UNIQUE INDEX abhi_1_UK ON abhi_1
    (l_number);
    

    I can also use below syntax for duplicates blocking (index will be created internally)

    create table abhi_1 
    ( l_number number, 
    constraint abhi_1_UK UNIQUE (L_number)
    )
    

    Please specify,

    Hello

    I would use a unique constraint.  Allows you to create foreign key constraints referencing the single column.

    As you said, when you create a unique constraint, Oracle automatically creates an index for it if necessary.  You can explicitly set the attributes of that index (for example, the name and tablespace) If you wish.

  • Error ' t CREATE UNIQUE INDEX W_PROD_CAT_DH_U1 ON W_PROD_CAT_DH

    Hello

    I use OLIVIER 7.9.6.4

    and EBS Instance ORA12.1.3

    I get below error when I tried to run full load for the DAC order management

    CREATE A UNIQUE INDEX

    W_PROD_CAT_DH_U1

    WE

    W_PROD_CAT_DH

    (

    INTEGRATION_ID Asc

    DATASOURCE_NUM_ID Asc

    EFFECTIVE_FROM_DT Asc

    )

    NOLOGGING

    ORA-01452: cannot CREATE a UNIQUE INDEX. duplicate keys found

    Among the responsible 1,45,423 records 24 140 are duplicated.

    Apart from the removal of duplicates of records in DB is there any changes that I can do in Informatica mapping to limit duplicate records to be loaded into DB.

    Any question even face to face only one?

    Kind regards

    NN.

    Hello

    For those who have faced the question above.

    Here is the Solution.

    1. Informatica PowerCenter Designer, place you in the SIL_Vert\Mappings folder and open the "SIL_ProductCategoryDimension_Hierarchy" mapping in the mapping Designer tool.
    2. Change the qualifier Source SQ_W_PRODCAT_DS to display the dialog box change Transformations and switch to the Properties tab.
    3. Select the name of the attribute processing Sql Query and edit the substitution of sql to change the status of outer join left in w_product_d as:
    4. DATABASE W_PRODCAT_DS
    5. LEFT OUTER JOIN W_PRODUCT_D PROD ON
    6. BASE. PROD_ID = PROD. INTEGRATION_ID AND PROD. CURRENT_FLG = 'Y '.
    7. Save the details and archive.


    The changes described above helped me load management command successfully.


    Kind regards

    NN.


  • 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.

  • (ORA-00955) conflict of naming for index and constraint when you use a unique index (.. desc,.. CSA)

    Hello

    indexes and constraints are in different namespaces, so it should be possible to give them the same name.

    In the following case that apparently does not work:

    create unique index orders_year_show_uq
      on orders (year desc, show_orders asc);
     
     alter table orders
      add constraint orders_year_show_uq unique (year, show_order);
    

    When I run these statement, I get a "SQL Error: ORA-00955: name is already used by an existing object". ""

    If I clean and I execute the same instructions as above with the only difference on the 2 line, using "asc year" instead of "year desc":

    
      on orders (year asc, show_orders asc);
    

    then it success.

    I can't explain it, you have an idea?

    Thanks in advance.

    Kind regards

    Giovanni

    First of all, you have show_orders in index and show_order in the constraint. I'll assume that it's a typo. Second, when you create constraint without index enhance the specification Oracle seeks indexes existing on the same set of columns in ascending order. If this index does not exist (and it's your case, since one of your columns to index is in descending order), Oracle tries to create one with the same name as the constraint. That's why you get ORA-00955: name is already used by an existing object. In general, you can specify explicitly the index name to force the Oracle by using the existing index. But it will not help you. If you issue

    ALTER table orders add unique constraint (year, show_orders) orders_year_show_uq using index orders_year_show_uq;

    You will get the ORA-14196: specified index cannot be used to apply the constraint.

    In any case, Oracle does not support using index DESC for PK/UK.

    SY.

  • abstract unique index

    Hi guru.

    The idea

    Let's say there's a transformation g: X = > Y

    for the normal unique index this transformation is the mapping on his own game.

    Let's now if I have another transformation that I defined. g' which maps to another set.

    Will I be able to define a unique index as such.

    For example.

    I have a sample of 1 to 1000000 of id

    and I have this g'(id) function of probability which gives the value of 0 to 1

    For example, g'(1) = 0.67 and g'(10) = 0.67

    so in this case if I id = 1 in my table I wouldn't have id = 10

    How can I do this in Oracle?

    create or replace function dettest (p number) deterministic return as number

    Start

    dbms_output.put_line ('in dettest');

    Return floor (p);

    end;

    /

    drop table xx;

    Select * from xx

    create table xx select level double x connect by level<=>

    Drop index xx_fbi

    create index xx_fbi on xx (dettest (x));

    create an index only xx_fbi_uni on xx (dettest (x));

    analyze table xx statistical calculation;

    exec dbms_output.put_line (' select 1 St: ');

    Select x, dettest (x) in xx;

    exec dbms_output.put_line (' 2nd select: "");

    Select x, dettest (x) in xx;

    Insert into xx select 1.2 double;

    Drop index xx_fbi_uni

    Insert into xx select 1.2 double;

  • 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.

  • Accompanied by primary key to a non-unique index?

    Met a weird situation today. A utility, we set up which allows analysts to restore the data in their paintings, started failed when it attempted to drop an index. The index supported a primary key. Makes sense. But our script was supposed to be only an attempt to drop/recreate the nonunique indexes. It turns out that supported on the primary key index was not unique and to the best of my knowledge has emerged as follows:
    SQL> create table junk (f number(1));
    
    Table created.
    
    SQL> create index junk_ix on junk(f);
    
    Index created.
    
    SQL> select UNIQUENESS from DBA_INDEXES where index_name = 'JUNK_IX';
    
    UNIQUENES
    ---------
    NONUNIQUE
    
    SQL> alter table forbesc.junk add constraint junk_pk primary key (f) using index junk_ix;
    
    Table altered.
    
    SQL> select UNIQUENESS from DBA_INDEXES where index_name = 'JUNK_IX';
    
    UNIQUENES
    ---------
    NONUNIQUE
    
    SQL> insert into junk values (1);
    
    1 row created.
    
    SQL> insert into junk values (1);
    insert into junk values (1)
    *
    ERROR at line 1:
    ORA-00001: unique constraint (FORBESC.JUNK_PK) violated
    
    
    SQL> select index_name from dba_constraints where constraint_name = 'JUNK_PK';
    
    INDEX_NAME
    ------------------------------
    JUNK_IX
    What I can't understand, is how an index is not unique is to apply oneness. I thought it was the key to this process. I thought that perhaps an index with the 'SYS_123456' has be created, perhaps, but I couldn't find a:
    SQL> select object_name, object_type from dba_objects order by created desc;
    
    
    OBJECT_NAME   OBJECT_TYPE
    -------------------------------------------     
    JUNK_IX     INDEX
    JUNK     TABLE
    ...
    How the uniqueness is get applied in this case? It comes in Oracle 11.1.0.7

    Thank you
    -= Chuck

    It has always been like that. Oracle can and will use a non-unique index to apply a constraint to PK, the existing index just needs to have the columns PK as the leader or the columns in the index:

    SQL> create table t (id number, id1 number, descr varchar2(10));
    
    Table created.
    
    SQL> create index t_ids on t(id, id1);
    
    Index created.
    
    SQL> select index_name from user_indexes
      2  where table_name = 'T';
    
    INDEX_NAME
    ------------------------------
    T_IDS
    
    SQL> alter table t add constraint t_pk
      2  primary key (id);
    
    Table altered.
    
    SQL> select index_name from user_indexes
      2  where table_name = 'T';
    
    INDEX_NAME
    ------------------------------
    T_IDS
    
    SQL> insert into t values (1, 1, 'One');
    
    1 row created.
    
    SQL> insert into t values (1, 2, 'Two');
    insert into t values (1, 2, 'Two')
    *
    ERROR at line 1:
    ORA-00001: unique constraint (OPS$ORACLE.T_PK) violated
    

    John

  • ORA-01502 error in the case of a unique index unusable and dml in bulk

    Hi all.

    The BP is 11.2.0.3 on a linux machine.

    I did a unique index unusable and issued a dml on the table.
    Howerver, oracle gave me the error ORA-01502.

    In order to avoid the ORA-01502 error, should I drop the unique index and bulk make dml and rebuild the index?

    Or is there another solution without recreating the unique index?
    create table hoho.abcde as
    select level col1 from dual connect by level <=1000 
    
    10:09:55 HOHO@PD1MGD>create unique index hoho.abcde_dx1 on hoho.abcde (col1);
    
    Index created.
    
    10:10:23 HOHO@PD1MGD>alter index hoho.abcde_dx1 unusable;
    
    Index altered.
    
    Elapsed: 00:00:00.03
    10:11:27 HOHO@PD1MGD>delete from hoho.abcde where rownum < 11;
    delete from hoho.abcde where rownum < 11
    *
    ERROR at line 1:
    ORA-01502: index 'HOHO.ABCDE_DX1' or partition of such index is in unusable state
    Thanks in advance.
    Best regards.
    Do I have to accept the unique index maintenance workload(undo generation/redo for undo generation)
    when doing bulk dml?
    

    I think so.

    The amount of data you load compared to existing data in the table?

    If say for example, you add 20%, and then to compare the retention of 20% adds data during the major part collect to create all of the index after insertion so
    you choose the drop/recreate the unique index

    Best regards

    Mohamed Houri
    www.hourim.WordPress.com

Maybe you are looking for