Add constraint  0ra-02299

Table has many records, some records are also duplicate (vm_no,vm_date)
now I am adding a constraint
SQL> alter table vouchermaster
  2  add constraint un_vm_vd unique (vm_no,vm_date);
add constraint un_vm_vd unique (vm_no,vm_date)
ERROR at line 2:
ORA-02299: cannot validate (UN_VM_VD) - duplicate keys foundFirst time I am using UN_VM_VD constraint name
when I check my table duplicate records
SQL> select vm_no,vm_date from vouchermaster
  2  group by vm_no,vm_date
  3  having count(1) >1;
     VM_NO VM_DATE
         5 18-MAY-10
         7 19-MAY-10
        18 19-MAY-10
        38 24-MAY-10guide me can I add constraint Unique or primary key without data lose with force.

Ahmed wrote:
guide me can I add constraint Unique or primary key without data lose with force.Adding unique or primary key constraint with "force" is not possible when duplicate keys exists. Duplicates must be removed first.
However, it is posssible to add this constraint in disabled state using "disable" keyword:
CREATE TABLE TEST763(
X NUMBER );
INSERT INTO TEST763 VALUES( 2 );
insert into test763 values( 2 );
COMMIT;
ALTER TABLE TEST763
ADD CONSTRAINT P_KEY PRIMARY KEY ( X ) ;
SQL Error: ORA-02437: nie można zweryfikować poprawności (TEST.P_KEY) - naruszenie klucza głównego
02437. 00000 -  "cannot validate (%s.%s) - primary key violated"
*Cause:    attempted to validate a primary key with duplicate values or null
           values.
*Action:   remove the duplicates and null values before enabling a primary
           key.
ALTER TABLE TEST763
ADD CONSTRAINT P_KEY PRIMARY KEY ( X ) DISABLE ;
ALTER TABLE TEST763 succeeded.Duplicates still must be removed before enabling the primary key/unique constraint.
ALTER TABLE TEST763
MODIFY CONSTRAINT P_KEY  ENABLE;
SQL Error: ORA-02437: nie można zweryfikować poprawności (TEST.P_KEY) - naruszenie klucza głównego
02437. 00000 -  "cannot validate (%s.%s) - primary key violated"
*Cause:    attempted to validate a primary key with duplicate values or null
           values.
*Action:   remove the duplicates and null values before enabling a primary
           key.

Similar Messages

  • Create a table from another table and add constraint statement. Please help

    Previously, I post a question and it works as below:
    create table my_table
    PCTFREE 10 PCTUSED 0 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
    INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
    TABLESPACE TAB_DATA
    as select t1, t5, t2, t3, t4 from orig_table;
    I have been trying to use the same strategy as I post earlier, but it doesn't work.
    CONSTRAINT "MY_TEMP" UNIQUE ("ID", "SNAME", "CNAME", "TIME", "SYSTEM_ID")
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "TAB_DATA" ENABLE
    CLUSTER MY_CLUSTER
    "CNAME"
    Below iis my SQL statement, but it doesn't work. Please help.
    create table my_table
    CONSTRAINT "MY_TEMP" UNIQUE ("ID", "SNAME", "CNAME", "TIME", "SYSTEM_ID")
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "TAB_DATA" ENABLE
    CLUSTER MY_CLUSTER
    "CNAME"
    as (select t1, t5, t2, t3, t4 from orig_table;

    Hi,
    Why do you need to combine the two action togather. You can get the things done in two steps.
    Create table tab1 as select * from tab2;
    Then you create any contraint that you want to create on tab2 using 'alter table add constraint'.
    Regards

  • Alter different users table, i need to add constraint: primary key

    Hi All,
    my oracle database : 10G
    I have a user named rahul and its trying to alter a table of a different user 'biapps_12'
    here is the alter table script that I am firing using user 'rahul' when connected to database 'MDMINT5' : alter table BIAPPS_12.W_PAYMENT_METHOD_D_O add constraint pk_W_PAYMENT_METHOD_D_O PRIMARY KEY (INTEGRATION_ID);
    Oracle error: [ORA-01031: insufficient privileges]
    PS: both these users are on the same database 'MDMINT5'
    2) I have an exclusive privilege which is [alter any table] but still I am getting this error.
    Please help me out.
    Regards
    Rahul

    If the user RAHUL genuinely has ALTER ANY TABLE then that user should be able to run the command you posted.
    Unless the privilege was granted through a role and the statement is being run as part of a PL/SQL block (through EXECUTE IMMEDIATE or similar contrivance). Anonymous blocks count as PL/SQL, and we cannot use privileges granted through roles in PL/SQL.
    Cheers, APC

  • 4EA1: Dual monitor - add constraint popup always appears on primary monitor

    When editing a table and going to the constraints tab, and clicking the green plus sign to specify the type of constraint, it always appears on the primary display.
    Environment:
    Windows 7 x64
    C:\Users\trent>java -version
    java version "1.7.0_04"
    Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
    Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode)
    http://oi39.tinypic.com/35klb0l.jpg

    I have two monitors.   The trick to moving something from the #1 Monitor to #2 monitor is to first
    click that button between the X and the - up at the top right of your screen in the blue bar.  Hover over it and it
    says "Restore Down".  This makes whatever you have on the screen less than full screen but
    still visible.
    Then you can grab it and move it over to the other screen.  (Left click, hold, and drag)  For some
    reason, a full screen view won't move, but the smaller screen view does.  Grab it and move it
    horizontally to the other screen.
    After you have it on the second screen in the smaller size, that Restore Down button becomes the
    Maximize button.  Click that and whatever you've moved will be full screen.
    My set-up is a little different because my #1 screen is to my left and is the smaller screen just
    because that's how my office is arranged.  I do my primary work on my #2 screen which is the
    larger screen. Programs open on #1 screen and I have to move them to #2 screen.

  • HOWTO: Add a UNIQUE constraint to a populated column

    Here is the way to add a unique constraint to a populated column, ensuring that the existing values are unique as well.
    ALTER TABLE t1
    ADD CONSTRAINT t1_uk UNIQUE (col1,col2)
    EXCEPTIONS INTO my_exceptions
    /If the alter table statement fails this will populate the MY_EXCEPTIONS table with the rows that contain duplicate values for (col1,col2). These are identified by ROWID. We can then chose to:
    [list]
    [*]delete rows with a bad key;
    [*]amend the values of the key columns;
    [*]re-apply the constraint with the NOVALIDATE option.
    [list]
    We should be wary of choosing the NOVALIDATE option. There's usually a good reason why the unique constraint is required and we should not circumvent it. Apart from anything else, Oracle allows us to build foreign keys referencing NOVALIDATE unique keys. This could result in child rows that have two parents, which is normal in biology, but very wrong in a database.
    NOVALIDATE is useful in datawarehouses and suchlike, because little updating occurs and the data integrity issues are of less imporatance. I don't think it ought to be used in OLTP situations. The code example at the end of this posting illustrates why we should exercise caution with NOVALIDATE.
    Once we have handled the duplicate values we can re-run the alter table statement and apply the constraint.
    If you don't already have an EXCEPTIONS table (it can be called anything, it's the structure that counts) you may need to run (or get a DBA to run) a script called UTLEXCPT.SQL, which will be in the $ORACLE_HOME/rdbms/admin directory.
    Cheers, APC
    SQL> SELECT col1, col2, col3 FROM t1;
          COL1       COL2       COL3                                               
             1          1          0                                               
             2          1          0                                               
             2          1          0                                               
    SQL> SELECT col1, col2, cola FROM t2;
          COL1       COL2 COLA                                                     
             1          1  I'm child #1                                                        
             1          1  I'm child #2                                                        
             2          1  I'm child #3                                                        
    SQL> ALTER TABLE t1
      2  ADD CONSTRAINT t1_uk UNIQUE (col1, col2);
    ALTER TABLE t1 ADD CONSTRAINT t1_uk UNIQUE (col1, col2)
    ERROR at line 1:
    ORA-02299: cannot validate (TST2.T1_UK) - duplicate keys found We can't add a unique key, so we decide to use the NOVALIDATE clause.
    SQL> CREATE INDEX t1_i ON t1(col1, col2);
    Index created.
    SQL> ALTER TABLE t1
      2  ADD CONSTRAINT t1_uk UNIQUE (col1, col2) ENABLE NOVALIDATE;
    Table altered.
    SQL> INSERT INTO t1 VALUES (2, 1, 1);
    insert into t1 values (2, 1, 1)
    ERROR at line 1:
    ORA-00001: unique constraint (TST2.T1_UK) violated Well, we can't add any more duplicate keys, so that's alright isn't it? Nope. We can add a foreign key to table T2 referencing T1 but we don't know which row in T1 is the parent of the rows in T2.
    SQL> ALTER TABLE t2
      2  ADD CONSTRAINT t2_t1_fk foreign key  (col1, col2)
      3  REFERENCES t1(col1, col2)
    Table altered.
    SQL> SELECT rowid FROM t1 WHERE col1 = 2;
    ROWID                                                                          
    AAAVnMAANAAAB96AAB                                                             
    AAAVnMAANAAAB96AAC                                                             
    SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAB';
    1 row deleted.
    SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAC';
    DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAC'
    ERROR at line 1:
    ORA-02292: integrity CONSTRAINT (TST2.T2_T1_FK) violated - child record found
    SQL> ROLL
    Rollback complete.
    SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAC';
    1 row deleted.
    SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAB';
    DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAB'
    ERROR at line 1:
    ORA-02292: integrity CONSTRAINT (TST2.T2_T1_FK) violated - child record found
    SQL>  ROLL
    Rollback complete.
    Why this matters: queries joining child and parent tables return more rows than we'd expect normally.
    SQL> SELECT t2.cola
      2  FROM   t2
      3  WHERE  t2.col1 = 2
      4  and    t2.col2 = 1;
    COLA                                                                           
    I'm child #3                                                                   
    SQL> SELECT t2.cola, t1.col4
      2  FROM   t1, t2
      3  WHERE  t2.col1 = 2
      4  AND    t2.col2 = 1
      5  AND    t1.col1 = 2
      6  AND    t2.col2 = 1;
    COLA                    COL4                                                   
    I'm child #3            I'm the daddy                                          
    I'm child #3            No, I'm the daddy!!                                    
    SQL> Caveat emptor
    This posting is issued on behalf of the Rogue Moderators. It is posted with the best of intentions but is not guaranteed in any way, shape or form. In particular, the code is presented "as is" and you assume full responsibility for running it on your system. Furthermore, you must not download and install software from the internet unless you know what you are doing and have the permission of whoever owns your system. It was never this hard for the Lone Ranger.

    Hi,
    You can not create unique key with duplicate values as you know. Now if you want to create unique key then you have to delete duplicate records from the table but this again if you can afford to delete because this data may be more importante to you and you can not delete any record.
    or you can use ENABLE NOVALIDATE option of oracle explain by Tom on below link.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:8806498660292
    or if you dont want to use Tom's way then you go with primary key like
    Drop old primary key if there is already on the column.
    create new primary key with enable novalidate option.

  • Add a unique constraint on binary XML table

    How add a unique constraint of "brevet" field?
    The following INSERT failed
    SQL Error: ORA-19025: EXTRACTVALUE renvoie la valeur d'un seul noeud
    19025. 00000 - "EXTRACTVALUE returns value of only one node"
    If the ALTER is made after the INSERT is done, INSERT is valid but ALTER failed with the same error message!
    /* copy the file compavions.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <compagnie>
         <comp>AB</comp>
         <flotte>
              <avion immat="F-WTSS" capacite="90">
                   <typeAv>Concorde</typeAv>
              </avion>
              <avion immat="F-GFDR" capacite="145">
                   <typeAv>A320</typeAv>
              </avion>
              <avion immat="F-GTYA" capacite="150">
                   <typeAv>A320</typeAv>
              </avion>
         </flotte>
         <nomComp>Air Blagnac</nomComp>
         <pilotes>
              <pilote>
              <brevet>PL-1</brevet>
              <nom>C. Sigaudes</nom>
              </pilote>
              <pilote>
              <brevet>PL-2</brevet>
              <nom>P. Filloux</nom>
              </pilote>
         </pilotes>
    </compagnie>
    in C:\...
    --DROP DIRECTORY repxml;
    --CREATE DIRECTORY repxml AS 'C:\...';
    DROP TABLE pilote_binary_xml5;
    CREATE TABLE pilote_binary_xml5 OF XMLType
    XMLTYPE STORE AS BINARY XML
    VIRTUAL COLUMNS
    (col AS (EXTRACTVALUE(OBJECT_VALUE, '/compagnie/pilotes/pilote/brevet')));
    ALTER TABLE pilote_binary_xml5 ADD CONSTRAINT brevet_unique UNIQUE (col);
    INSERT INTO pilote_binary_xml5 VALUES (XMLType(BFILENAME ('REPXML','compavions.xml'), NLS_CHARSET_ID ('AL32UTF8')));
    --ALTER TABLE pilote_binary_xml5 ADD CONSTRAINT brevet_unique UNIQUE (col);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You could try something like
    (extract(OBJECT_VALUE,compagnie/pilotes/pilote/brevet').getStringVal());
    but this is probably unadvisable.
    I suggest an alternative is for you to look at XMLINDEX so that you can bring the 'proper' XML functions into play like XMLTABLE etc.

  • How to add multiple constraints

    Hi,
    I would like to alter the table to add multiple constraints. Can it be done in one statement or I have to have multiple statements? Thanks.
    alter table
    table_name
    add constraint
    constraint_1,
    add constraint
    constraint_2

    SQL> create table foo( col1 number, col2 number );
    Table created.
    SQL> alter table foo
      2    add( constraint pk_foo primary key( col1 ),
      3         constraint uk_foo unique( col1, col2 ),
      4         constraint chk_foo check( col2 in (1,2) ) );
    Table altered.Justin

  • How do you add a CONSTRAINT for a VARCHAR(10) column to checks the Date format as yyyy/mm/dd

    I have tried:
    ALTER TABLE dbo.tablename
    ADD CONSTRAINT DF_Date_format
    check (SDate LIKE '%[1-2][0-9][0-9][0-9]/[0-1][0-9]/[0-3][0-9]%')
    ******But this does not work for VARCHAR data type ********
    and
    I also tried creating a function as shown below but I got an error when trying to add a constraint with this function.
    (error is:
    'The ALTER TABLE statement conflicted with the CHECK constraint "DF_Date_format". The conflict occurred in database " databasename ", table "dbo.tablename", column 'Date'.)
    Create FUNCTION [dbo].[CheckDateFormat]
    (@Date varchar(10))
    Returns BIT
    AS
    BEGIN
    Declare @RETURN BIT
    SELECT @Return =
    Case when (substring (@Date, 5, 1) + substring (@Date, 8, 1)) = '//'
    then 0
    else 1
    end
    Return @Return
    END
    ALTER TABLE dbo.tablename
    ADD CONSTRAINT DF_Date_format
    check
    ( dbo.CheckDateFormat(SDate) = 0 )

    As noted above, be mindful of the performance implications of UDF CHECK constraints:
    http://www.sqlusa.com/bestpractices/udf-check-constraint/
    The following logic works:
    Create FUNCTION [dbo].[CheckDateFormat]
    (@Date varchar(10))
    Returns BIT
    AS
    BEGIN
    Declare @RETURN BIT
    SELECT @Return =
    Case when (substring (@Date, 5, 1) + substring (@Date, 8, 1)) = '//'
    then 0
    else 1
    end
    Return @Return
    END
    GO
    CREATE TABLE Orders (ID INT IDENTITY(1,1),
    OrderDate varchar(10),
    Amount money
    GO
    ALTER TABLE Orders
    ADD CONSTRAINT DF_Date_format
    check
    ( dbo.CheckDateFormat(OrderDate) = 0 )
    GO
    As noted above, DATE is a better choice for column data type.
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • SQL Data Modeler adds blank line to UK Constraints

    Oracle SQL Developer Data Modeler Version: 2.0.0 Build: 584
    I'm migrating my schema designs from Oracle Designer to SQL Developer Data Modeler. When I get to the point of generating SQL files I consistently get an extra blank line added to every unique constraint. My primary key constraints are defined the same way, but they do not have the blank line. See below for an example of the SQL output:
    ALTER TABLE ALIAS
    ADD CONSTRAINT ALIAS_PK PRIMARY KEY ( ALIAS_NO )
    USING INDEX TABLESPACE INDEX1
    NOLOGGING
    NOSORT
    ALTER TABLE ALIAS
    ADD CONSTRAINT ALIAS_UK UNIQUE ( ALIAS_NAME )
    USING INDEX TABLESPACE INDEX1
    NOLOGGING
    NOSORT
    This blank line causes errors when I execute the SQL script so I have to edit it before using. Did I forget to something or is this a bug?
    Thanks,
    Gail Binkley
    Stanford University

    Hi Gail,
    thanks for feedback. I logged bug for that.
    Philip

  • Add unique constraint only if it not exists

    hello racle community,
    I would like to create a unique constraint (at least over two columns) on several tables via a script. Is there any way to fire the ALTER TABLE statement only when a constraint over the same columns does not exists already ? Or do I have to query the USER_CONSTRAINTS table first ?
    Ikrischer

    Yes, something like this:
    set serveroutput on
    declare
      UNIQUE_CONS_EXISTS exception;
      pragma  exception_init(UNIQUE_CONS_EXISTS, -2261); 
    begin
      for r in (select table_name
                      ,rownum rn
                from all_tables where ....) loop
        begin
          execute immediate 'alter table ' || r.Table_Name || ' add constraint i_' || r.rn || ' unique (col1,col2)';
          when UNIQUE_CONS_EXISTS then
            dbms_output.put_line(sqlerrm);
          end;
      end loop;
      dbms_output.put_line('Done');
    end;
    /The only thing to bear in mind is that your constraint names will simply be numbered increments and will have no meaning.

  • Add a foriegn key constraint to to a sub type on an object table

    Hi,
    I'm trying to set up a new table of an object type in our DB at work and on it I want to create a foreign key constraint on one of the attributes of one of the sub types
    The table is called documents and is a table of document_ot
    Definition:
    create or replace
    TYPE document_ot AS OBJECT (
    -- ATTRIBUTES
    created_date DATE,
    created_by VARCHAR2( 32 ),
    doc_id NUMBER,
    -- CONSTRUCTORS
    ) NOT INSTANTIABLE NOT FINAL;
    This type is extended by the type funding_certificates_ot
    create or replace
    TYPE funding_certificate_ot UNDER document_ot (
    -- ATTRIBUTES
    fc_prefix VARCHAR2( 2 ),
    fc_sequence NUMBER,
    fc_suffix VARCHAR2( 1 ),
    fc_pr_id NUMBER,
    -- CONSTRUCTORS
    -- METHODS
    ) NOT FINAL;
    I want to add a constraint to the to documents table that says that the funding_certificate_ot column fc_pr_id references pr_id in the table payruns.
    I've managed to create an index on the fc_pr_id column using:
    CREATE INDEX fc_pr_idx
    ON documents d (treat (value(d) as funding_certificate_ot).fc_pr_id);
    The code I thought I'd use for the foreign key constraint would be:
    ALTER TABLE documents d
    ADD CONSTRAINT doc_pr_fk FOREIGN KEY
    treat (value(d) as funding_certificate_ot).fc_pr_id
    REFERENCES payruns
    (pr_id)
    ENABLE;
    But that doesn't work - would someone be able to give me the correct syntax please?
    Many thanks

    Hi,
    I'm trying to set up a new table of an object type in our DB at work and on it I want to create a foreign key constraint on one of the attributes of one of the sub types
    The table is called documents and is a table of document_ot
    Definition:
    create or replace
    TYPE document_ot AS OBJECT (
    -- ATTRIBUTES
    created_date DATE,
    created_by VARCHAR2( 32 ),
    doc_id NUMBER,
    -- CONSTRUCTORS
    ) NOT INSTANTIABLE NOT FINAL;
    This type is extended by the type funding_certificates_ot
    create or replace
    TYPE funding_certificate_ot UNDER document_ot (
    -- ATTRIBUTES
    fc_prefix VARCHAR2( 2 ),
    fc_sequence NUMBER,
    fc_suffix VARCHAR2( 1 ),
    fc_pr_id NUMBER,
    -- CONSTRUCTORS
    -- METHODS
    ) NOT FINAL;
    I want to add a constraint to the to documents table that says that the funding_certificate_ot column fc_pr_id references pr_id in the table payruns.
    I've managed to create an index on the fc_pr_id column using:
    CREATE INDEX fc_pr_idx
    ON documents d (treat (value(d) as funding_certificate_ot).fc_pr_id);
    The code I thought I'd use for the foreign key constraint would be:
    ALTER TABLE documents d
    ADD CONSTRAINT doc_pr_fk FOREIGN KEY
    treat (value(d) as funding_certificate_ot).fc_pr_id
    REFERENCES payruns
    (pr_id)
    ENABLE;
    But that doesn't work - would someone be able to give me the correct syntax please?
    Many thanks

  • How to add a FK-constraint on an attribute

    Hi,
    I've got an xml file which looks like this:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <ScheduledDay ProgramDate="01-05-2003" Channel="CANVAS" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://wxpp-heremha:8080/teledemo/configuration/EPG.xsd">
         <ScheduledProgram ProviderScheduleId="9000">
              <StartHour>20:00</StartHour>
              <EndHour>21:00</EndHour>
              <Title>TerZake Zomer</Title>
              <Duration>60</Duration>
              <EditionNr>5</EditionNr>
    and a table "Channels" with a channel_cd.
    I would like to put a FK-constraint on the "Channel"-attribute of the "ScheduledDay"-element.
    Is there anyone who knows the correct syntax?
    Thanks in advance!!!
    Regards
    Hans

    To use referential integrity you must use object relational storage, that is you have to register an XML Schema.
    For better usability you might add an schema annotation SQLName="ATT_CHANNEL" or anyling like this. So in the attribute definition in the XML schema should look like this:
    <xs:attrtibute name="Channel" xdb:SQLName="ATT_CHANNEL" ...>
    After you have registred the XML Schema, there is a table automatically created. So you can add the constraint like this:
    alter table ... add constraint fk_... foriegn key (xmldata.att_channel) references ...
    You'll find more Info in the XML DB Basic Demo.
    http://otn.oracle.com/tech/xml/xmldb/demonstrations/xdbBasicDemo.zip
    Description:
    http://otn.oracle.com/tech/xml/xmldb/demonstrations/9202_Demonstration.pdf

  • JPA - How can i add ON DELETE CASCADE constraint ?

    I have a three tables.
    1. A (name)
    2. B (name)
    and relationship(manytomany) table of A and B
    3. C (a_name,b_name)
    I am using 2 JPA entities@Entity
    public class A {
         @id
         String name;
         @ManyToMany
         @JoinTable(name="C",
                   joinColumns=@JoinColumn(name="a_name"),
                   inverseJoinColumns=@JoinColumn(name="b_name"))
         private List<B> bs = new ArrayList<B>();
         //getter setter methos
    }and@Entity
    public class B {
         @id
         String name;
         @ManyToMany(mappedBy="bs")
         private List<A> as = new ArrayList<A>();
         //getter setter methos
    }DDL of table C which is generated by JPA is something like thatCREATE TABLE C (
    "a_name" VARCHAR,
    "b_name" VARCHAR,
    CONSTRAINT "c_a_name_fkey" FOREIGN KEY ("a_name")
    REFERENCES a(name)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
    CONSTRAINT "c_b_name_fkey" FOREIGN KEY ("b_name")
    REFERENCES b(name)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
    )but i want to add constraint ON DELETE CASCADE* instead of ON DELETE NO ACTION_ in above relationship table C.
    how can i do this ?
    Thanks in advance.

    Right click the message and select Edit as New.

  • How add primary key constraint to already existing table with data

    I want apply primary key constraint to already existing table with data
    is there any command or way to do

    Alternatively, assuming you want to ensure uniqueness in your primary key column you can do this:
    alter table <table name> add constraint <cons name> primary key (col1,col2) exceptions into <exception_table>
    If the altter table statement fails this will populate the EXCEPTIONS table with the rows that contain duplicate values for (col1,col2).
    You will need to run (or get a DBA to run) a script called UTLEXCPT.SQL (which will be in the $ORACLE_HOME/rdbms/admin directory) if you don't already have an EXCEPTIONS table.
    Cheers, APC

  • Adding Constraint add extra Index....Why?

    Hi,
    I am creating an index with a field that is function based:
    CREATE INDEX vicc_veh_info##code_year ON vicc_veh_info(UPPER(car_code), model_year DESC, PROGRESS_RECID);
    Now when I create the following constraint:
    ALTER TABLE BILLITEM ADD CONSTRAINT PK_BILLITEM PRIMARY KEY (BUSINESSOBJECTNUM,BUSOBJSEQUENCE,OBJECTNUM,ITEM_NUMBER,ITEMPOST_TYPE);
    It actually creates the constraint and it also creates another Index with the same name as the constraint so when I look at the index it is called PK_BILLITEM and when I look at the table I also see that constraint there as well.
    Why is it doing this. Why does this constraint not just created on it's own???
    Is this because of the function based column in the Index.

    Which index did you specify? The syntax, as per the examples, tells you you can say
    USING INDEX {provide the index definition}
    USING INDEX {provide the name of an existing index}
    Message was edited by: Hans Forbrich
    Copy/paste from the link:
    CREATE TABLE promotions_var3
        ( promo_id         NUMBER(6)
        , promo_name       VARCHAR2(20)
        , promo_category   VARCHAR2(15)
        , promo_cost       NUMBER(10,2)
        , promo_begin_date DATE
        , promo_end_date   DATE
        , CONSTRAINT promo_id_u UNIQUE (promo_id, promo_cost)
             USING INDEX (CREATE UNIQUE INDEX promo_ix1
                ON promotions_var3 (promo_id, promo_cost))
        , CONSTRAINT promo_id_u2 UNIQUE (promo_cost, promo_id)
             USING INDEX promo_ix1);

Maybe you are looking for

  • Can not open remote files

    Code allows me to open a web folder on a local server but not to open an individual html file. Do files have to be located on local hard drive in order to open and edit? Back to Dreamweaver...

  • Published my iWeb files to MobileMe but can't get to domain

    I've finally been able to publish my iWeb files to MobileMe (after 2 days of trying -- a message kept appearing that said "iWeb couldn't publish to MobileMe. The MobileMe servers are busy. Please try again in a few minutes."), but now when I try to g

  • Query on Forms Personalization of Oracle Assignment Form

    Hi All, My customer has a requirement of personalization on the Assignment form. They would like to show the People group flex field segments but make them non-editable. Since the People Group is a KFF, I am unable to figure out how to personalize th

  • How to bold/italics/underline specific text (not default) in Calendar Ver 7?

    See above.  I've already tried Ctrl+ U/I/B and Command + U/I/B The app = Calendar Version 7.0 (1835.1) in Mac OS X.  Looking to select specific text in the Notes/Attachments/URL portion of the appointment and mark it up.  We can do this right?  MS Of

  • HT4566 how do i view tiff files in safari?

    Wanting to view drawings on uspto.gov in Tiff won't open in Safari Mountail LIon...  Anybody?