SQL Unique Key

hello guys, I created one table and with 15 columns on it.
Is it possible on one Table; column 1 -3 are unique columns 4 -6 - are not unique columns then 7 -10 are unique columns and 11 to 15 are not unique columns.
How do I do it?
Thank you.
Every second counts..make use of it. Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.
IT Stuff Quick Bytes

you can have many UNIQUE constraints per table, but only one PRIMARY KEY constraint per table.
major difference is that primary key doesn’t allow NULLs, but unique key allows one NULL only.
ADD CONSTRAINT uc_Name UNIQUE (Columnname1,Columnname2)
Please Mark This As Answer if it helps to solve the issue

Similar Messages

  • *** [23000][2627][Microsoft][SQL Server Native Client 11.0][SQL Server]Violation of UNIQUE KEY constraint 'ClientPushMachine_G_AK'. Cannot insert duplicate key in object 'dbo.ClientPushMachine_G'. The duplicate key value is (16777412). : sp_CP_CheckNewAss

    *** [23000][2627][Microsoft][SQL Server Native Client 11.0][SQL Server]Violation of UNIQUE KEY constraint 'ClientPushMachine_G_AK'. Cannot insert duplicate key in object 'dbo.ClientPushMachine_G'. The duplicate key value is (16777412). : sp_CP_CheckNewAssignedMachine
    CCCRT::RunSQLStoredProc - Failed to execute SQL cmd exec [sp_CP_CheckNewAssignedMachine] N'xxx', 1
    CCRQueueRequest::GetRequestFromQueue - Failed to execute SQL cmd sp_CP_CheckNewAssignedMachine
    I get the above issue and the one below at a client site; the error started with the error below then changed to the one reported above and back to the one below. Everything is working as it should but the issues
    started when one of the admins at the data-centre incorrectly applied a gpo which affected a number of service accounts (sccm inclusive) and they expired....hence reporting in sccm got broke as well as this error in the ccm.log file appeared.
    Remote client install still works but I believe this error affects new client discovered by sccm, so in other words devices discovered by sccm do not get the client installed automatically....but if all access and permissions are in place...pushing out the
    client to the new discovered system works, it just not done automatically, which kinda defeats one the reasons for using sccm.
    I have searched the breadth of the tinternet and I can only find two technet reference to the same error  - one says to edit the stored procedure on the sql server which I don't think should be done... Like Jason said and I concur....its bad joo joos.
    The second suggestion, said you should select all the options in the Client Push Installation properties, I have tried this but hasn't solved the problem.
    I am planning to upgrade the site to the R2 CU3 before the end of the year but I would like to resolve this error before the upgrade.
    The site is currently sccm 2012 sp1 
    Any idea?> Resolution? sil vous plait!
    Merci

    Hi ,
    Please back up the database of the SCCM site. Then run the following query against the Site DB and see how it goes.
    DELETE FROM System_SMS_Resident_ARR
    WHERE ItemKey IN (
    SELECT ItemKey FROM vSystem_SMS_Resident_ARR
    GROUP BY ItemKey
    HAVING COUNT(ItemKey) > 1
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • Is their a difference between primary key and unique key with not null valu

    What is the difference in having a column as primary key and having unique key with not null for the column.
    vinodh

    SBH wrote:
    For quick review, below is the link
    http://www.dba-oracle.com/data_warehouse/clustered_index.htm
    You appear to have stumbled on a site that is a mine of disinformation about Oracle.
    >
    It would be helpful, if you explain it too..thnx !!
    The site is wrong and makes up its own terminology as it goes along.
    If the value for clustering factor approaches the number of blocks in the base table, then the index is said to be clustered. http://www.oracle.com/pls/db112/search?remark=quick_search&word=clustered+index
    There is no create clustered index in Oracle.
    - Clustering factor affects the efficiency of an index.
    - There can be clustered tables that you can create indexes on.
    - An Index Organized table is a similar concept to the Microsoft SQL Server clustered index, but it isn't the same thing at all.

  • Unique Key Violation While Doing Multiple Updates And Create in EJB

    Hello All,
    I am using oracle 9i and Weblogic 7.0. I have a table that has a unique key constraint on one column , say 'Col1' and i am using a CMP to read,create and update data in this table. The problem description is as follows.
    I have JTable that display the data from the above said table. The user can modify the existing data and insert new data that will be reflected in the DB using the CMP. Let us say the following are displayed
    ROW1
    Col1 : 3
    Col2 : 'ABC'
    Col3 : 1 (Primary key in the table)
    Now the user modifies the above row and inserts a new record. Now the following will be the display
    ROW1 (Modified)
    Col1 : 4
    Col2 : 'ABC'
    Col3 : 1 (Primary key in the table)
    ROW2 (New)
    Col1 : 3
    Col2 : 'DEF'
    Col3 : 2 (Primary key in the table)
    When the above data is saved i do the following in the Code
    a) Session Bean
    For (all the data in the Jtable)
    try
    home.findByPrimaryKey(Col3);
    remote.update(Col1,Col2);
    catch(FinderException fe)
    home.create(Col1,Col2,Col3);
    When the above code is run During the first loop the update runs succesfully (i.e update old value of 3 with 4 ) but during the 2nd loop the create (i.e Insert new value 3) gives me the unique key violated exception. The following is the stack trace
    <Oct 25, 2004 11:36:22 AM IST> <Info> <EJB> <010049> <EJB Exception in method: ejbPostCreate: java.sql.SQLException: ORA-00001: unique constraint (UAT_CYCLE2_1.UK_PYMT_DET_TX) violated
    java.sql.SQLException: ORA-00001: unique constraint (UAT_CYCLE2_1.UK_PYMT_DET_TX) violated
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:579)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1892)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
    at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2130)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2013)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2869)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
    at weblogic.jdbc.jts.Statement.executeUpdate(Statement.java:509)
    at de.dl.ucs.contract.entity.TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.__WL_create(TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.java:1435)
    at de.dl.ucs.contract.entity.TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.ejbPostCreate(TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.java:1353)
    at java.lang.reflect.Method.invoke(Native Method)
    at weblogic.ejb20.manager.DBManager.create(DBManager.java:1023)
    at weblogic.ejb20.manager.DBManager.localCreate(DBManager.java:904)
    at weblogic.ejb20.internal.EntityEJBLocalHome.create(EntityEJBLocalHome.java:180)
    at de.dl.ucs.contract.entity.TerminalPaymentsCMP_kbdoop_LocalHomeImpl.create(TerminalPaymentsCMP_kbdoop_LocalHomeImpl.java:73)
    at de.dl.ucs.contract.helperclasses.SubsegmentMaintanence.saveTerminalPayments(SubsegmentMaintanence.java:697)
    at de.dl.ucs.contract.controller.SubsegmentSL.saveSubsegmentDetails(SubsegmentSL.java:570)
    at de.dl.ucs.contract.controller.SubsegmentSL.processFinanceSubsegmentSave(SubsegmentSL.java:1601)
    at de.dl.ucs.contract.controller.SubsegmentSL_kgzv4j_EOImpl.processFinanceSubsegmentSave(SubsegmentSL_kgzv4j_EOImpl.java:498)
    at de.dl.ucs.contract.events.FinanceSubsegmentBEH.saveSubsegmentDetails(FinanceSubsegmentBEH.java:749)
    at de.dl.ucs.contract.events.FinanceSubsegmentBEH.processEvent(FinanceSubsegmentBEH.java:232)
    at de.dl.ucs.framework.flowcontroller.ControllerBean.delegateAction(ControllerBean.java:229)
    at de.dl.ucs.framework.flowcontroller.ControllerBean_riqvk4_EOImpl.delegateAction(ControllerBean_riqvk4_EOImpl.java:46)
    at de.dl.ucs.framework.flowcontroller.ControllerBean_riqvk4_EOImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:441)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:382)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:726)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:377)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:234)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:210)
    >
    <Oct 25, 2004 11:36:22 AM IST> <Info> <EJB> <010051> <EJB Exception during invocation from home: [email protected] threw exception: javax.ejb.TransactionRolledbackLocalException: EJB Exception:; nested exception is: java.sql.SQLException: ORA-00001: unique constraint (UAT_CYCLE2_1.UK_PYMT_DET_TX) violated
    Please help me with this, as far as i am concerned since both update and create is in the same transaction the update on the row must be visible to the create and hence there shouild not be any problem.....
    thanks in advance
    Shanki

    Hi,
    Thanks,
    There are 3 columns involved with that table . Out of whihc one is a Primary Key (string) , The other column (Number) has a unique key constraint defined on it and the last column stores a value corresponding to the 2nd column.
    The reason for me to do a create in the Finder exception is as follows.
    I Loop through the Data present in JTable. As given in the example let us assume that there are 2 rows in the JTable. Out of whihc the First row needs an updation and the second row , which is a new row needs to be created. So During the First iteration of the loop, The findermethod does not throw any exception (Because it is a modfied row) and hence the update gets fired successfully. During the second iteration , since it is a new row the findermethod will throw a finder exception and hence create will get fired.
    I understand that this is not a good coding style but then it is not 100% wrong and i need to find out as to why it is not working.
    Hope am clear in explaining my problem
    Thanks
    Shanki

  • Unique Key Violation error while updating table

    Hi All,
    I am having problem with UNIQUE CONSTRAINT. I am trying to update a table and getting the violation error. Here is the over view. We have a table called ActivityAttendee. ActivityAttendee has the following columns. The problem to debug is this table has
    over 23 million records. How can I catch where my query is going wrong?
    ActivityAttendeeID INT PRIMARY KEY IDENTITY(1,1)
    ,ActivityID INT NOT NULL (Foreign key to parent table Activity)
    ,AtendeeTypeCodeID INT NOT NULL
    ,ObjectID INT NOT NULL
    ,EmailAddress VARCHAR(255) NULL
    UNIQUE KEY is on ActivityID,AtendeeTypeCodeID,ObjectID,EmailAddress
    We have a requirement where we need to update the ObjectID. There is a new mapping where I dump that into a temp table #tempActivityMapping (intObjectID INT NOT NULL, intNewObjectID INT NULL)
    The problem is ActivityAttendee table might already have the new ObjectID and the unique combination.
    For example: ActivityAttendee Table have the following rows
    1,1,1,1,NULL
    2,1,1,2,NULL
    3,1,1,4,'abc'
    AND the temp table has 2,1
    So essentially when I update in this scenario, It should ignore the second row because, if I try updating that there will be a violation of key as the first record has the exact value. When I ran my query on test data it worked fine. But for 23 million records,
    its going wrong some where and I am unable to debug that. Here is my query
    UPDATE AA
    SET AA.ObjectID = TMP.NewObjectID
    FROM dbo.ActivityAttendee AA
    INNER JOIN #tmpActivityMapping TMP ON AA.ObjectID = TMP.ObjectID
    WHERE TMP.NewObjectID IS NOT NULL
    AND NOT EXISTS(SELECT 1
    FROM dbo.ActivityAttendee AA1
    WHERE AA1.ActivityID = AA.ActivityID
    AND AA1.AttendeeTypeCodeID = AA.AttendeeTypeCodeID
    AND AA1.ObjectID = TMP.NewObjectID
    AND ISNULL(AA1.EmailAddress,'') = ISNULL(AA.EmailAddress,'')

    >> I am having problem with UNIQUE CONSTRAINT. I am trying to update a table and getting the violation error. Here is the over view. We have a table called Activity_Attendee. <<
    Your problem is schema design. Singular table names tell us there is only one of them the set. Activities are one kind of entity; Attendees are a totally different kind of entity; Attendees are a totally different kind of entity. Where are those tables? Then
    they can have a relationship which will be a third table with REFERENCES to the other two. 
    Your table is total garbage. Think about how absurd “attendee_type_code_id” is. You have never read a single thing about data modeling. An attribute can be “attendee_type”, “attendee_code” or “attendee_id”but not that horrible mess. I have used something like
    this in one of my busk to demonstrate the wrong way to do RDBMS as a joke, but you did it for real. The postfix is called an attribute property in ISO-11179 standards. 
    You also do not know that RDBMS is not OO. We have keys and not OIDs; but bad programmers use the IDENTITY table property (NOT a column!), By definition, it cannot be a key; let me say that again, by definition. 
    >> ActivityAttendee has the following columns. The problem to debug is this table has over 23 million records [sic: rows are not records]<<
    Where did you get “UNIQUE KEY” as syntax in SQL?? What math are you doing the attendee_id? That is the only reason to make it INTEGER. I will guess that you meant attendee_type and have not taken the time to create an abbreviation encoding it.
    The term “patent/child” table is wrong! That was network databases, not RDBMS. We have referenced and referencing table. Totally different concept! 
    CREATE TABLE Attendees
    (attendee_id CHAR(10) NOT NULL PRIMARY KEY, 
     attendee_type INTEGER NOT NULL  --- bad design. 
        CHECK (attendee_type BETWEEN ?? AND ??), 
     email_address VARCHAR(255), 
    CREATE TABLE Activities
    (activity_id CHAR(10) NOT NULL PRIMARY KEY, 
    Now the relationship table. I have to make a guess about the cardinally be 1:1, 1:m or n:m. 
    CREATE TABLE Attendance_Roster
    (attendee_id CHAR(10) NOT NULL --- UNIQUE??
       REFERENCES Attendees (attendee_id), 
     activity_id Activities CHAR(10) NOT NULL ---UNIQUE?? 
      REFERENCES Activities (activity_id)
     PRIMARY KEY (attendee_id, activity_id), --- wild guess! 
    >> UNIQUE KEY is on activity_id, attendee_type_code_id_value_category, object_id, email_address <<
    Aside from the incorrect “UNIQUE KEY” syntax, think about having things like an email_address in a key. This is what we SQL people call a non-key attribute. 
    >> We have a requirement where we need to update the ObjectID. There is a new mapping where I dump that into a temp table #tempActivityMapping (intObjectID INTEGER NOT NULL, intNewObjectID INTEGER NULL) <<
    Mapping?? We do not have that concept in RDBMS. Also putting meta data prefixes like “int_” is called a “tibble” and we SQL people laugh (or cry) when we see it. 
    Then you have old proprietary Sybase UODATE .. FROM .. syntax. Google it; it is flawed and will fail. 
    Please stop programming until you have a basic understanding of RDBMS versus OO and traditional file systems. Look at my credits; when I tell you, I think I have some authority. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Difference between Unique key and Primary key(other than normal difference)

    Hello,
    1).Can any one tell me any other difference between Unique key and Primary key other than it having NULLs.
    2). What is the difference the words 'DISTINCT' and 'UNIQUE' in a sql query.
    Thanks in advance.

    Hi
    If you don't believe me than see the documentation in
    OTN.
    Ott Karesz
    http://www.trendo-kft.hu
    SQL> create table scott.tbl_clob
      2  (sss CLOB)
      3  /
    Tabelle wurde angelegt.
    SQL> insert into scott.tbl_clob values('wrwrwrw')
      2  /
    1 Zeile wurde erstellt.
    SQL> insert into scott.tbl_clob values('wrwrwrw')
      2  /
    1 Zeile wurde erstellt.
    SQL> select distinct sss from scott.tbl_clob
      2  /
    select distinct sss from scott.tbl_clob
    FEHLER in Zeile 1:
    ORA-00932: nicht übereinstimmende Datentypen
    SQL> select unique sss from scott.tbl_clob
      2  /
    select unique sss from scott.tbl_clob
    FEHLER in Zeile 1:
    ORA-00932: nicht übereinstimmende Datentypen
    SQL> select distinct to_char(sss) from scott.tbl_clob
      2  /
    TO_CHAR(SSS)
    wrwrwrw
    SQL> select unique to_char(sss) from scott.tbl_clob
      2  /
    TO_CHAR(SSS)
    wrwrwrw
    SQL>

  • Primary key,Froign key , Unique key

    I want the answer of following questions.
    1) Primary key create cluster index or simple index?
    2) What is cluster index : I know only( cluster index stored record at physical level in sorted order) if there is another difference then tell me
    3) Can I set relation ship with unique key if it is specified with NOT NULL constraints in a table.
    4) Foreign key creates a index or not?

    Hello
    I want to be at least 6 inches taller, better looking and really good at playing the drums, but that's neither here nor there.
    A simple please never hurts.
    For answers to the first 2 I'd concentrate on the clusters section of the concepts guide as your understanding of what clusters are for and when they should be used appears to be lacking:
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96524/c11schem.htm#25479
    and also have a look at this asktom thread:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:6996872588440689863::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:1308402202736
    The last two questions, again you can find the info you need in the concepts guide but
    3) Can I set relation ship with unique key if it is specified with NOT NULL constraints in a table.To set up a foreign key from one table to another, it needs to reference a primary key or a unique key in the target table, the NOT NULL constraint has very little to do with it. A very simple test will show this:
    SQL> create table dt_test(id number);
    Table created.
    SQL> create table dt_test_fk(id number);
    Table created.
    SQL> create table dt_test_fk(id number, pk_id number);
    Table created.
    SQL> alter table dt_test_fk add constraint fk_dt_test_fk FOREIGN KEY(pk_id) references dt_test(id);
    alter table dt_test_fk add constraint fk_dt_test_fk FOREIGN KEY(pk_id) references dt_test(id)
    ERROR at line 1:
    ORA-02270: no matching unique or primary key for this column-list
    SQL> alter table dt_test add constraint uk_dt_test UNIQUE (id);
    Table altered.
    SQL> alter table dt_test_fk add constraint fk_dt_test_fk FOREIGN KEY(pk_id) references dt_test(id);
    Table altered.
    SQL> alter table dt_test modify(id number not null);
    Table altered.
    4) Foreign key creates a index or not? Creating a foreign key on a column does NOT automatically create an index on that column.
    A primary key may create a new index. If an index is already available on the table and it can be used i.e the leading edge of the index holds the columns in the primary key, it will be used rather than creating a new one.
    HTH

  • The order of a DBDataSource - A unique key (index) can help (but...)

    Hi @all!
    There was often the question, if a DBDataSource could be ORDERed BY sth. Although it would be nice if somebody could disprove that: It's not possible.
    Up to this my experience was that the "items" in a DBDataSource always ordered by the Code-Column. That's what my code in some situations relys on. For example if a B1-form browses by a DBDataSource then the order is not always user friendly based on a column with data the user knows.
    But today I was surprised: "Suddenly" a DBDataSource-browsing form is browsing correctly by a DB-Column which the user is interested in (instead of the code-column) !
    The reason for this is a unique UserKey, which I've created by SDK (UserKeysMD). The form seems to browse by the columns of the key.
    But the common reason seems to be that it's standard SQL-behaviour because doing a simple query (without ORDER BY) in SQL-Management Studio also sorts the results by the unique key.
    But there's one important question left:
    Which key wins and why? There's also the unique index for Code on that table....
    Cheers,
    Roland

    Hello @Petr & @all ,
    last night I came to the conclusion, that I must re-implement the browsing for the 6 existing forms with own code:
    Stepping through a recordset with the data of the Ex-BrowseBy EditTxt with defined ORDER
    Then loading the form with DBDataSource which is restricted by conditions to exactly ONE dataset on each arrow-step. I hope/think it works - I will inform you.
    And here are some things to sort out with David {german - sorry}:
    Hallo David,
    ich habe hier kein UDO verwendet weil...
    ...die Forms viele spez. Funktionen haben die dadurch nicht (oder nur komplizierter) möglich wären.
    ...hauptsächlich aber weil die betroffenen Tabellen auch von einer Schnittstelle zur Betr.-Datenerfassung "gespeist" werden (also nur über DI)
    BrowseBy funktioniert ja auch ohne UDO über ein EditTxt welches an eine column in der tabelle DBDataBinded ist und für das "BrowseBy" aktiviert ist.
    Dies ist für die Tabelle/Formular mit den Hauptobjekten auch ok: es wird automatisch durch alle Hauptobjekte geBrowsed und nach Code wäre zumindest chronologisch alles richtig gewesen (auch nicht schön von dieser Vorgabe abhängig zu sein - hat sich ja jetzt aber erledigt, da die Indexe alles undefiniert würfeln)
    Die Sache wird aber noch etwas komplizierter, da die Hauptobjekte drei mal in Unterobjekte aufgeteilt sind, für die es jeweils auch Formulare gibt. Und diese Formulare sollen nur innerhalb eines Teils der zugehörigen Untertabelle browsen. In der Untertabelle sind aber alle Unterobjekte aller Hauptobjekte enthalten.
    Also habe ich für die Unterobjekt-Form die DBDataSource nach der geBrowsed wird mit Conditions eingeschränkt. Schon hier mußten die Pfeile mit eigener Funktion belegt werden (B1 automatik reicht da nicht)
    Beim browsen in den Unterobjekten ist durch die indexe natürlich nun auch alles durcheinander.
    Das ganze fiel auch nicht sofort ins Auge weil "meistens" Code und eigentliche ObjektSchlüssel durch "chronologische" Eingabe (bzw. import) die gleiche Reihenfolge haben.
    Nur ein Versuch das "mal so eben" zu erklären...
    Viele Grüße,
    Roland

  • How to use Unique key constraint in EJB

    Hi All,
    I am using an entity bean to create my table in MySQL4.1.13
    I have a table called user which has userid,username,password as its columns.
    The userid is a primary key over here.
    But I want the user name to be unique.
    I.e if a user with the name 'Adrian' is present in the database then another user with this user name should not be created.
    I have been told that you can configure a unique key in jbosscmp-jdbc.xml using insert-after-ejb-post-create.
    But i dont know how to use it.
    Can anyone give me a sample code for using this.
    Any help would be appreciated.
    Thanks
    P2

    Please explain your problem better. Really can't figure what you are trying to do.....
    choosing which sql statement to use at runtime
    or creating dynamic sql statement at runtime
    which??
    Regards

  • About Unique Key

    Hi all,
    I have a table with only one col..called...Rno...with unique..constraint.
    In this table i can enter more than one null value...If i can enter more than one null value...the concept of unique may get false...
    please explain whether a unique key accept more than one null value or not..
    Thanks and regards
    MKK

    NULL = NULL is always false actually you mean
    NULL = NULL is always null
    add a constant to your index and enjoy unique nulls :-)
    SQL> create table t(x number);
    Table created.
    SQL> create unique index i on t(x,1);
    Index created.
    SQL> insert into t values(1);
    1 row created.
    SQL> insert into t values(2);
    1 row created.
    SQL> insert into t values(2);
    insert into t values(2)
    ERROR at line 1:
    ORA-00001: unique constraint (SCOTT.I) violated
    SQL> insert into t values(null);
    1 row created.
    SQL> insert into t values(null);
    insert into t values(null)
    ERROR at line 1:
    ORA-00001: unique constraint (SCOTT.I) violatedMessage was edited by:
    Laurent Schneider
    the technical reason why unique index i on t(x) is not unique is that nulls are not indexed

  • Java OracleXML putXML & non-unique keys

    I am using the XML SQL Utility for java on the client (NT) to insert multi-row XML documents into an ORACLE table. Everything works fine until I hit a row with a non-unique key. It appears insertXML throws an error and the insert stops at that point. Rows after the non-unique key row are not processed.
    Is there any way to process all rows of an XML document, telling me how many read, how many inserted, how many not processed??
    Also, what about update capabilities? Presently I am not needing to update from XML into ORACLE, all I can do now is insert.
    Thanks in advance,
    Rick

    One way to make this work would be to take advantage of Oracle8i's INSTEAD OF triggers on views.
    Basically, you would:
    (1) CREATE VIEW someview
    AS SELECT * FROM sometable;
    (2) CREATE TRIGGER someview_trig
    INSTEAD OF INSERT ON someview
    DECLARE
    BEGIN
    -- Check for existence of
    -- row using the value of
    -- :NEW.pk_column_name
    IF (you-found-an-existing-one) THEN
    -- Do something here like
    -- NULL; to ignore the insert altogether
    -- or possible an INSERT into
    -- and EXCEPTIONS table...
    ELSE
    INSERT INTO sometable
    VALUES (:NEW.column1, ..., :NEW.columnn);
    END IF;
    END;
    (3) Then point XML SQL Utility at someview
    instead of sometable
    and you'll be in business, as they say.

  • AMT enrollment error - Violation of UNIQUE KEY constraint 'EN_EnrollmentRecords_AK'.

    Hello,
    I've trouble enrolling AMT computer with SCCM 2012
    I've foud the following error in Amtproxymgr.log
    15/05/2014 14:54:50     
    Found instruction file: D:\Apps\Microsoft Configuration Manager\inboxes\amtproxymgr.box\{C6B0AAB5-BB02-4673-B44A-118917419389}.OTP
    15/05/2014 14:54:50     
    It's client provisioning request to be processed.
    15/05/2014 14:54:50     
    Stored provisioning request into database. SMSID: Machine_GUID
    15/05/2014 14:54:50     
    Target machine SMSID:Machine_GUID is a AMT capable machine.
    15/05/2014 14:54:50     
    Passed SanityCheckBeforeProvision(). FQDN is MYCOMPUTERNAME.domain.
    15/05/2014 14:54:50     
    BASE64 string OTP is : OTP_STRING
    15/05/2014 14:54:58      *** EN_EnrollmentAdminInsert @ProfileId = '16777217', @AssignedSiteCode = N'SITE_CODE', @DeviceName = N'MYCOMPUTERNAME', @ResourceID = '16816953', @OwnerIdentity = N'', @ClientType
    = '1', @OrganizationUnit = N'LDAP://OU=OU_NAME
    15/05/2014 14:54:58     
    *** [23000][2627][Microsoft][SQL Server Native Client 11.0][SQL Server]Violation of UNIQUE KEY constraint 'EN_EnrollmentRecords_AK'. Cannot insert duplicate key in object 'dbo.EN_EnrollmentRecords'. The duplicate key value is (MYCOMPUTERNAME). : EN_EnrollmentAdminInsert
    15/05/2014 14:54:58     
    Fail to insert Enrollment Record!
    15/05/2014 14:54:58     
    Error: Failed to create enrollment record.
    If I do a query on V_R_SYSTEM the resource ID for MYCOMPUTERNAME is 16816953.
    If I do a query on EN_EnrollmentRecords the Ressource Id associated  to
    MYCOMPUTERNAME is 16777351
    So there is already a record for MYCOMPUTERNAME in
    EN_EnrollmentRecords.
    I think the reason is that the computer resource has been removed from SCCM and then readded. The computer has now a new Ressource ID. But the deletion of the previous computer ID did not removed the record from
    EN_EnrollmentRecords.
    How can I solve this ?

    Open Sql Server Management Studio, and do the query below.
    select * from dbo.en_EnrollmentRecords where ResourceID ='16777351'
    delete from dbo.EN_EnrollmentRecords where ResourceID = '16777351'
    Delete the Device from console and AD and try provisioning again.
    Note: Please backup your Database before doing this modification. Modifying database will be at your own risk.
    Juke Chou
    TechNet Community Support

  • GG Error of unique key,

    Hi,
    While setting up goldengate i have come accross the following error in the error log. This error occurs when extract in started.
    2010-08-06 18:53:58 INFO OGG-00476 Oracle GoldenGate Capture for Oracle, ext-a.prm: Gathering metadata for [SEND.SOURCE] not successful even though object was resolved, retrying [3] times with 1 second interval.
    2010-08-06 18:53:59 WARNING OGG-00455 Oracle GoldenGate Capture for Oracle, ext-a.prm: Problem in resolving [SEND.SOURCE]: OCI error (904-ORA-00904: "VISIBILITY": invalid identifier) building query to fetch unique key, SQL < SELECT key.key_name, key.column_name, key.descend FROM (SELECT c.constraint_name key_name, c.column_name column_name, c.position position, >, try to fix this issue in order to avoid possible fatal error.
    2010-08-06 18:53:59 INFO OGG-00476 Oracle GoldenGate Capture for Oracle, ext-a.prm: Gathering metadata for [SEND.SOURCE] not successful even though object was resolved, retrying [2] times with 1 second interval.
    2010-08-06 18:54:00 WARNING OGG-00455 Oracle GoldenGate Capture for Oracle, ext-a.prm: Problem in resolving [SEND.SOURCE]: OCI error (904-ORA-00904: "VISIBILITY": invalid identifier) building query to fetch unique key, SQL < SELECT key.key_name, key.column_name, key.descend FROM (SELECT c.constraint_name key_name, c.column_name column_name, c.position position, >, try to fix this issue in order to avoid possible fatal error.
    2010-08-06 19:07:13 ERROR OGG-00521 Oracle GoldenGate Capture for Oracle, ext-a.prm: Object was resolved, however in the same resolution call both DDL history and database metadata resolution failed, cannot recover, SCN [489507], object id [51514].
    note that my table does contain unique key
    Any ideas? Stuck at this stage :(
    thanks
    Salman

    Hi Dominik
    I managed to correct that one. It was actually the name of my trails are different on primary node and remote node.
    Now i am attempting to configure bidirectional traffic but during this phase the repilcat 1 dies (abending).
    Log shows up as follows
    2010-08-06 21:42:21 INFO OGG-00996 Oracle GoldenGate Delivery for Oracle, rep-a.prm: REPLICAT REP-A started.
    2010-08-06 21:42:21 WARNING OGG-01004 Oracle GoldenGate Delivery for Oracle, rep-a.prm: Aborted grouped transaction on 'RECV.DEST', Database error 100 (retrieving bind info for query).
    2010-08-06 21:42:21 WARNING OGG-01003 Oracle GoldenGate Delivery for Oracle, rep-a.prm: Repositioning to rba 1653 in seqno 1.
    2010-08-06 21:42:21 WARNING OGG-01154 Oracle GoldenGate Delivery for Oracle, rep-a.prm: SQL error 1403 mapping SEND.SOURCE to RECV.DEST.
    2010-08-06 21:42:21 WARNING OGG-01003 Oracle GoldenGate Delivery for Oracle, rep-a.prm: Repositioning to rba 1653 in seqno 1.
    2010-08-06 21:42:21 ERROR OGG-01296 Oracle GoldenGate Delivery for Oracle, rep-a.prm: Error mapping from SEND.SOURCE to RECV.DEST.
    2010-08-06 21:42:21 ERROR OGG-01668 Oracle GoldenGate Delivery for Oracle, rep-a.prm: PROCESS ABENDING.

  • Howto check all tables if have unique key

    I need to check all tables if they have unique key. If they do not i must print it.
    How can i make this in PL/SQL
    regards

    But dba_constraints is not storing the information when i establish a unique constraint by creating unique index.
    SQL> create table t as select level no from dual connect by level <= 10
      2  /
    Table created.
    SQL> create unique index t_idx on t(no)
      2  /
    Index created.
    SQL> select distinct table_name
      2    from user_indexes
      3   where uniqueness = 'UNIQUE'
      4     and table_name = 'T'
      5  /
    TABLE_NAME
    T
    SQL> select * from dba_constraints where constraint_type = 'U' and table_name = 'T'
      2  /
    no rows selected
    SQL> select * from dba_constraints where table_name = 'T'
      2  /
    no rows selected
    SQL> select * from user_constraints where table_name = 'T'
      2  /
    no rows selected
    SQL>But on the other hand user_indexes has it in all case
    SQL> drop table t
      2  /
    Table dropped.
    SQL> create table t(no number unique)
      2  /
    Table created.
    SQL> select distinct table_name
      2    from user_indexes
      3   where uniqueness = 'UNIQUE'
      4     and table_name = 'T'
      5  /
    TABLE_NAME
    T
    SQL> select * from dba_constraints where table_name = 'T'
      2  /
    OWNER                          CONSTRAINT_NAME                C TABLE_NAME                     SEARCH_CONDITION
                            R_OWNER                        R_CONSTRAINT_NAME              DELETE_RU
    STATUS   DEFERRABLE     DEFERRED  VALIDATED     GENERATED      BAD RELY LAST_CHAN INDEX_OWNER            INDEX_NAME                     INVALID VIEW_R
    ELATED
    SYSADM                         SYS_C00391103                  U T
    ENABLED  NOT DEFERRABLE IMMEDIATE VALIDATED     GENERATED NAME          02-SEP-08 SYSADM                 SYS_C00391103Thanks,
    Karthick.

  • JDBC : Unique key

    Hello
    1) Wanted to understand when we insert record into a oracle table from PI , is primary key always required to be created in table structure ?
    2) for updates a key would be looked , if a record already exists it would be an update. what is the command for inserting into a table which has to be put in mapping logic ? we have pi 7.1
    3) can a combination of 5 keys be like a unique key defined in PI ?
    Thnx

    1) Wanted to understand when we insert record into a oracle table from PI , is primary key always required to be created in table structure ?
    No, key is not mandatory. But I believe that you will always update records with some conditions. If you always want to update all the existing records without any conditions, then it's a weird but still technically possible case.
    2) for updates a key would be looked , if a record already exists it would be an update. what is the command for inserting into a table which has to be put in mapping logic ? we have pi 7.1
    I guess you are missing the concepts of DB and your question is confusing. You can use key depending on the query that you have formed, for update / insert.
    Elaborate your requirement. if you have a SQL query, provide it here.
    3) can a combination of 5 keys be like a unique key defined in PI ?
    Yes, you can define 'n' number of keys in the mapping.

Maybe you are looking for

  • Using MA to migrate from a G5 running 10.4.11 to a new iMac running 10.6.2

    OK, So I'm an IT professional but I'm working on my husband's machine which introduces a whole new set of risks - like staying married He has an old G5 running Tiger and I just got him the new i5 for Christmas. I'm getting ready to migrate everything

  • Three Hour Twitch

    ...bought a film scanner...after installing the drivers and connecting it I get a message that it cannot communicate with the computer... ...oh no... ...what could it be?..damn BIOS again?..SP2?..memory?..vidcard?...PSU?...SATA HDD (I don't have one)

  • [SOLVED] XMonad + dzen2

    I have been staring at this for the last day and I can't figure out why it isn't working.  I cannot for the life of me get topBarCmd or botBarCmd to show up; I pretty much copied these configs from one of my working systems, and just edited them for

  • I am facing random troubles on my spanking new MacBook Pro 17".

    Hello! I recently bought an Apple MacBook Pro 17" and I am facing a few problems every now and then: 1. Sometimes, clicking on the trackpad with two fingers stops invoking the right-click function and it only starts doing so on the next reboot. 2. So

  • Cannot edit photo in iBook

    After placing a photo on an ibook page, I try to edit it. I highlight the picture & click on options. When I click on "edit photo" it goes to that menu, but the photo does not appear. Just black. Any ideas on why that may be? I've already made a book