How to create Unique constraint

Hi,
How can I create a unique constraint on a column in a table which has already been created.
Thanks

ALTER TABLE your_table ADD CONSTRAINT yrt_uk UNIQUE (some_col)
/You may find it illuminating to read the online documentation.
Cheers, APC

Similar Messages

  • How to create unique constraint in ODI

    Hi
    I have view at source side, I want to store source data to target interface table.
    For that I need to create UNIQUE constraint at source side to identify the unique records.
    I have composite primary key example as follow
    desc Test_V;
    orderID NUMBER,
    itemNumber NUMBER,
    productId NUMBER,
    quantity NUMBER,
    lot_number varchar2(80)
    where
    PRIMARY KEY (orderID, itemNumber,lot_number);
    Some times, lot_number can be null, So, I can't use lot_number in composite key (as per requirement)
    Please any body can help me on it
    Thanks
    Phani

    Hi
    Hope this may help
    http://mhimu.wordpress.com/2009/05/04/odi-incremental-update-and-surrogate-key-using-database-sequence/
    but some cases it is not working
    Thanks
    Phani

  • How to create unique constraint on a col which has duplicate values

    Hi all,
    how can i create a unique constraint on a field which have duplicate vaules with no validate clause.
    My table name is "ACCT"
    Regards
    Message was edited by:
    53637

    Check out following
    SQL>DROP TABLE TEST;
    Table dropped.
    SQL>CREATE TABLE TEST
      2  (
      3     ID          NUMBER
      4    ,NAME        VARCHAR2(30)
      5    ,CITY        VARCHAR2(30)
      6  );
    Table created.
    SQL>INSERT INTO TEST VALUES(1,'Rajesh','Gurgaon');
    1 row created.
    SQL>INSERT INTO TEST VALUES(1,'Rajesh','Gurgaon');
    1 row created.
    SQL>INSERT INTO TEST VALUES(2,'Dinesh','Delhi');
    1 row created.
    SQL>INSERT INTO TEST VALUES(1,'Rajan','Pune');
    1 row created.
    SQL>INSERT INTO TEST VALUES(1,'Rajan','Pune');
    1 row created.
    SQL>COMMIT;
    Commit complete.
    SQL>ALTER TABLE test ADD CONSTRAINTS uk_on_test UNIQUE(ID,NAME,CITY) DEFERRABLE NOVALIDATE ;
    Table altered.
    SQL>ALTER TABLE test
      2  ENABLE NOVALIDATE CONSTRAINT uk_on_test;
    Table altered.
    SQL>INSERT INTO TEST VALUES(1,'Rajesh','Gurgaon');
    INSERT INTO TEST VALUES(1,'Rajesh','Gurgaon')
    ERROR at line 1:
    ORA-00001: unique constraint (AIP.UK_ON_TEST) violatedRegards
    Arun

  • Create unique constraint on table

    Hello experts,
    Is it possible to define a unique constraint on table fields that aren't part of the primary key?
    Thank you in advance.

    One way is to create an index on the field and make it unique (SE11->GOTO->Indexes). Then in your programs Inserts, Appends and Updates would fail giving you a non zero SY-SUBRC when a program tries to enter a value that already exists.
    Don't forget to include MANDT in the index otherwise you'll end up with uniqueness across all clients

  • How to Catch Unique Constraint in Exception

    Hi,
    I am writing a trigger TR_EMP on a table EMP which has columns EMP_ID, EMP_NAME, ALT_EMP_ID.
    Now I am updating ALT_EMP_ID for an EMP_ID(PK) which is unique.
    If ALT_EMP_ID is null
    then
          :new.ALT_EMP_ID = l_alt_emp_id;
    end if;As this ALT_EMP_ID is unique, same ID shouldn't be inserted again here. When data being inserted with 2 different sessions for 2 different EMP_ID there is a possible chance of inserting same ALT_EMP_ID for both which results in Unique error. I need to handle this exception. DUP_VAL_ON_INDEX or OTHERS Execption not able to handle this.
    Can you help me out on how to handle such exception?

    >
    jeneesh wrote:
    I am able to use dup_val_on_index
    >
    Can you please write an Exception for this query?
    If ALT_EMP_ID is null
    then     
          :new.ALT_EMP_ID = l_alt_emp_id;
    end if;jeneesh wrote:
    Moreover, what is your requirement? This design seems to be flawed. If you can explain teh actual requirement, forum members will be able to help you better..
    >
    Alternate Emp ID will be populated for Every employee. If on a same session when this ID is populated for 2 different Emplyoees then it will throw Unique constraint error, which should be handled.

  • How to create unique index on a View

    Hi All,
    11.2.0.1
    How do I create an index on a view or any workaround that my view wont get duplicates?
    SQL> create unique index indx01 on db_backup_details_vw(id);
    create unique index indx01 on db_backup_details_vw(id)
    ERROR at line 1:
    ORA-01702: a view is not appropriate here
    Thanks a lot,
    Kinz

    I'm thinking of using a distinct clause here.
    if i get 5 duplicate rows in my selection set because of the join condition, can't i discard the remaining 4 using a distinct clause.
    Observe this
    SQL> select * from a;
    T1 T2
    1 4
    2 4
    3 4
    SQL> select * from b;
    T1 T2
    1 4
    2 5
    in both a,b t1 is the primary key. so we'll write a join on t2 (non PK).
    SQL> select b.t1,b.t2 from a,b where a.t2=b.t2;
    T1 T2
    1 4
    1 4 -- duplicates
    1 4
    Now create view with distinct clause
    create view ab as select distinct b.t1,b.t2 from a,b where a.t2=b.t2;
    SQL> select * from ab;
    T1 T2
    ---------- ---------- -- no duplicates
    1 4
    CSM

  • How to create Unique Identifier and save it to identify user(device)

    I want to create unique identifier on iOS 5 and use it for identifying user (user device) every time app is started. I am able to create a unique identifier by following code 
    CFUUIDRef theUUID = CFUUIDCreate(NULL);
    CFStringRef string = CFUUIDCreateString(NULL, theUUID); CFRelease(theUUID);
    But unable to save it on user device so that particular identifier is not deleted even when app is uninstalled. I tried using SSKeychain approach but it gives Apple Mach-o Linker error.
    Please let me know the the way I can accomplish the same.
    Any help is appreciated.

    I want to create unique identifier on iOS 5 and use it for identifying user (user device) every time app is started. I am able to create a unique identifier by following code 
    CFUUIDRef theUUID = CFUUIDCreate(NULL);
    CFStringRef string = CFUUIDCreateString(NULL, theUUID); CFRelease(theUUID);
    But unable to save it on user device so that particular identifier is not deleted even when app is uninstalled. I tried using SSKeychain approach but it gives Apple Mach-o Linker error.
    Please let me know the the way I can accomplish the same.
    Any help is appreciated.

  • How to create unique objects in class and store

    Hi, I have a class that opens a text file and reads in the
    lines. each line holds an ip address. i need to create x amount of
    objects, and each object is assigned a unique ip address from the file.
    and here i am stuck. the class reads in the file, then i think it should create an object for each line read in and assign that object the ip address. i want to store the objects in some sort of array or collection, and i guess each object will need a unique name, but i dont know how many objects until i read in the file and count the number of lines. can anyone give me any pointers as to how i should create/store the objects
    many thanx
    ness

    You could use your own object:
    public class Test {
      public class IPNumber {
        public int ip;
        public IPNumber(int ip) {
          this.ip = ip;
      public Test() {
        int numberOfIPs = 5; // this is your number of lines
        IPNumber[] ips = new IPNumber[numberOfIPs];
        for (int i = 0; i < numberOfIPs; i++) ips[i] = new IPNumber(i); // assign ip address from file
      public static void main(String args[]){
        new Test();
    }or you could store the ips as strings:
    public class Test {
      public Test() {
        final int numberOfIPs = 5; // this is your number of lines
        final java.util.ArrayList al = new java.util.ArrayList(numberOfIPs);
        for (int i = 0; i < numberOfIPs; i++) al.add(""+i); // assign ip address from file   
      public static void main(String args[]){
        new Test();
    }p.s Objects don't have names

  • How to create unique sequence number

    Hello,
    I'm new to ODI and trying to learn. Below is the requirement. Please advise.
    I'm trying to load data from one database (oracle) to another database table (AS400). But when i load the data into AS400, I need to create a unique ID for each record and write this unique ID to one of the fields in AS400.
    I don't have any issues loading the data from oracle to AS400. But I'm unable to generate a unique ID for each record. Can any share your thoughts how to get this.
    Thanks for your help.

    Hi ,
    First, on the DB2/400 instance, create a table containing an Identity column:
    CREATE TABLE THE_IDENTITY_TAB
    (THE_IDENTITY_COL DECIMAL(31,0) GENERATED ALWAYS AS IDENTITY
    START WITH 1000,
    INCREMENT BY 1);
    Second, in the same DB2/400 instance, create a function that returns an incremented number from the Identity column:
    CREATE FUNCTION NEXT_IDENTITY_COL () RETURNS DECIMAL(31,0)
    LANGUAGE SQL
    MODIFIES SQL DATA
    BEGIN
    INSERT INTO THE_IDENTITY_TAB VALUES (DEFAULT);
    DELETE FROM THE_IDENTITY_TAB;
    RETURN (SELECT identity_val_local() FROM QSYS2.QSQPTABL);
    END
    Finally, in Designer, use the snpRef.getObjectName() substitution method to refer to the DB2/400 function in the interface's mapping for the appropriate field:
    <%=snpRef.getObjectName("L","NEXT_IDENTITY_COL","<LOGICAL_SCHEMA_NAME>","D")%>()
    Thanks,
    Sutirtha

  • How to create Unique Number.

    I need to create a Unique Request Number for System.
    how Can i create this in Oracle.
    Regards,
    Agrawal's

    I have One table Says PRINT_MGMT_LOG & in this table there are more than 10 columns, so can i create SEQUENCE in this table or should i make a new table having one column to store these running number.
    Which one will be better considering performance issues.

  • How to create unique notification sounds for email on Droid Incredible 4G LTE

    I have three separate email accounts pushed to my Droid Incredible 4G LTE.  I can't for the life of me figure out how to set up unique notification sounds for each email account.  It was a snap to do on my old Blackberry.
    Same question for flagging individuals within my contact list.  (E.g., if my wife calls it makes one sound, if a client calls it makes a different sound.)
    Does anyone know how to do this, or, as they say, is there an app for that???
    Thanks in advance!

    I don't think you can on the email but got to each contact and edit them for different sounds, I'm not sure if it works on that new phone that way but as they don't have a dedicated room yet for it you had nowhere else to ask htc has good forums also

  • How to create unique key column in ROLAP fact table?

    Hi all,
    Is there a way to create a single column primary key (or unique index) on my ROLAP cube (and fact tables) in OWB? if so, what I should do in my mappings?
    Thanks!
    - Andrew

    Have you all conformed dimensions between the two facts?

  • How to create unique shapes in Illustrator CS4

    First off....
    I am new to the Adobe suite of applications and also new to owning a Macbook Pro. I have been using a design program for Windows for many years.
    I would like to master the creation and manipulation of shapes using Illustrator CS4.
    As one example, how would I create the following:
    I want to end up with a shape that is similar to one-quarter of a full moon.
    Using my Windows program (not an Adobe product), I would create a line using a line tool, and then I would be able to convert that line to a curve using a shape tool, which would enable me to drag from the midpoint of the line and have it become an arc. Then, while still using the shape tool, I could click once to select one of the endpoint nodes to then click on an "auto-close" option which would add a straight-line edge to close the shape for outline and fill purposes (so one side of the shape is straight at this point and the other side is curved). Using the shape tool, I would double-click near the midpoint of the straight edge to add a new node to the shape, and then I would use the "convert to curve" option from within the shape tool to be able to drag this straight side towards the curved side to end up with the quarter-moon shape as desired.
    How would I make this sort of shape using Illustrator, and as a general question for learning, how can I learn all about how to put lines in the design space for purposes of joining these lines, curving any part of one or more lines and then filling or outlining the finished shape made from joined lines?

    > and as a general question for learning, how can I learn all about how to put lines in the design space for purposes of joining these lines, curving any part of one or more lines and then filling or outlining the finished shape made from joined lines?
    Well, you can read the documentation. That will be much more thorough and methodical than asking a random series of "how do I..." questions in a user forum. And it will take you
    a lot less time.
    > Using my Windows program (not an Adobe product)
    You can say the name. If there's actually anyone here who doesn't know other drawing programs exist, well, they
    need to. Your description sounds like Xara Xtreme.
    > I want to end up with a shape that is similar to one-quarter of a full moon..create a line...convert that line to a curve...drag from the midpoint of the line and have it become an arc...select one of the endpoint nodes... "auto-close"...double-click near the midpoint of the straight edge to add a new node..."convert to curve"...drag...
    A similar procedure could be used in just about any vector drawing program that draws cubic Bezier curves. A much quicker procedure could also be used in just about any program, by leveraging the geometric shape tools and path combination commands that are just as ubiquitous:
    1. Draw a circle.
    2. Duplicate the circle.
    3. Overlap the circles partially.
    4. Use one circle to "punch" the other, leaving the difference (the crescent shape).
    Here are two AI-specific differences I note in your description:
    Illustrator can't bend a straght segment by dragging its middle if the straight segment has both its associated curve handles retracted. Dragging such a segment in AI just moves the segment (and its associated anchorPoints).
    Illustrator displays fills on open paths. There is no option to turn off that often unwanted behavior.
    Again, read the manual (the online Help files). It will take you decades to learn the program by asking random questions on the basic use of the tools, location of commands, organization (well, disorganization) scheme of the program, etc., etc.
    JET

  • How to create unique object for dynamically created jTextFields

    Hello to all forum members
    According to my requirement , i have created a number of jpanels(containing textfield,comboboxes etc) and added them to a jScrollPane.
    But my requirement is after adding the jPanels to the JScrollPanel, i want to add some logic to that jpanels; like
    1) i want to sort the panels according to some condition when a sort button is clicked
    2)and the text field which are in the panel should be sorted according to the integer value inside the text field.
    3) and after a buton clicked the value what are in the jText field should store in the data base etc.....
    For the above logic to apply i need the instance variable(i.e object reference ) should be difference, so that when i want to get a value from any component ( text from jtextfield ) i can get the value through its instance variable name.for example
    JTextField textField1=new JTextField("aaa");
    JTextField textField2=new JTextField("cccc");
    JTextField textField3=new JTextField("eee");then
    textField1.getText();
    textField2.getText();
    textField3.getText();But the problem is when i am creating the number of panels the name of the instance variables (of all the components i.e textfield ,panels)are same so i can't add the logic to any particular component.
    I have tried to solve this problem , but not getting any idea .Please help me to find out the solution. I hope i explained my problem clearly if not
    tell me i will explain it again.
    I have given here with the code in which i have created 100 jpanels , each jpanels consisting of 1label and 1text field but the instance variable for each component is same.
    Plese help me to solve this problem,Thanks in advance.
    import javax.swing.*;
    public class NestedPanels extends JFrame
      private static final int NO_OF_NESTED_PANELS = 100;
      public NestedPanels()
        super("Nested Panels");
        setSize(200, 200);
        JPanel mainPanel = new JPanel();
        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
         for ( int i=1; i<=NO_OF_NESTED_PANELS; i++)
             mainPanel.add(createChildPanel(i));
         javax.swing.JScrollPane jScrollPane = new javax.swing.JScrollPane();
         jScrollPane.setViewportView(mainPanel);
        getContentPane().add(jScrollPane);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
      private JPanel createChildPanel(int intChildPanelNumber)
        JPanel childPanel = new JPanel();
        childPanel.setLayout(new BoxLayout(childPanel, BoxLayout.X_AXIS));
        childPanel.add(new JLabel("" + intChildPanelNumber));
        childPanel.add(new JTextField());
        return childPanel;
      public static void main(String[] argv)
        javax.swing.SwingUtilities.invokeLater(new Runnable()
          public void run()
            NestedPanels example = new NestedPanels();
    }Thanks & Regards
    Mahendra

    Hi to all forum members,
    Thanks for all your help.
    JayDS, as you have told i have tried with
    return Integer.valueOf( getText() ).compareTo( Integer.valueOf( mp.getText() ) );but it is giving
    java.lang .NumberFormatException.forInputString(unknown source)
    sorry i could not get what is SSCE?
    I am sending the code here with my requirement.
    My requirement is to sort the panels.
    i.e.
    when I will click on to the sortC1 button , the whole panels should be sorted according to the integer value inside the textfield1 (but here in my code it is sorting string wise,if u enter 1,2 ,1111111,3 ,222 the output should be 1,2,3, ,222 ,1111111 but it is actually giving the output as 1, 1111111,2,222,3 which is wrong )
    Arrays.sort(NestedPanelSorting); => this method is used for sorting
    return getText().compareTo(mp.getText());=> method is used for the text comparision in the example ( NestedPanelSorting.java)
    sortC2 also same.
    When I will click sortC3 ,the panel will be sorted according to the string values in the dropdown of combo boxes. Here how to access the instance of combobox to sort or the panel or through array of objects how can i sort?
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Arrays;
    import javax.swing.*;
    public class NestedPanelSorting extends JFrame
        private static final int NO_OF_NESTED_PANELS = 10;
        private MyPanel[] NestedPanelSorting = new MyPanel[NO_OF_NESTED_PANELS];
        //MyPanel[] is a array of MyPanel objects declared below
         private JPanel mainPanel;
        private JScrollPane jScrollPane;
         public NestedPanelSorting()
            super("Nested Panels Sorting");
            setSize(400, 200);
            mainPanel = new JPanel();
            mainPanel.setLayout(new BoxLayout(mainPanel,BoxLayout.Y_AXIS));
            //in the for loop below MyPanel(i) is called through NestedPanelSorting[i]
              for (int i = 0; i < NestedPanelSorting.length; i++)
                NestedPanelSorting[i] = new MyPanel(i);
                mainPanel.add(NestedPanelSorting);
    jScrollPane = new javax.swing.JScrollPane();
    jScrollPane.setViewportView(mainPanel);
    getContentPane().add(jScrollPane, BorderLayout.CENTER);
    JButton myBtn1 = new JButton("sortC1");
              JButton myBtn2 = new JButton("sortC2");
              JButton myBtn3 = new JButton("sortC3");
    getContentPane().add(myBtn1, BorderLayout.EAST);
    getContentPane().add(myBtn2, BorderLayout.WEST);
    getContentPane().add(myBtn3, BorderLayout.SOUTH);
              myBtn1.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent arg0)
    myButtonAction(arg0);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setVisible(true);
    private void myButtonAction(ActionEvent arg0)
              //this Array.sort() method is for sorting the array -
              // accordig to string value but i need to sort integer value wise
    Arrays.sort(NestedPanelSorting);
              mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel,
    BoxLayout.Y_AXIS));
    for (int i = 0; i < NestedPanelSorting.length; i++)
    mainPanel.add(NestedPanelSorting[i]);
    jScrollPane.setViewportView(mainPanel);
         public static void main(String[] argv)
    javax.swing.SwingUtilities.invokeLater(new Runnable()
    public void run()
    new NestedPanelSorting();
    //declaring of MyPanel class where textfield1,txtField2,comboBox1 are added
         class MyPanel extends JPanel implements Comparable<MyPanel>
    private int number;
    private JTextField txtField1;
              private JTextField txtField2;
    private JComboBox comboBox1;
    public MyPanel(int number)
                   super();
    this.number = number;
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    add(new JLabel(String.valueOf(number)));
    txtField1 = new JTextField();
    add(txtField1);
                   txtField2 = new JTextField();
    add(txtField2);
                   comboBox1=new JComboBox();
                   comboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ITEM  1 ", "ITEM  2 ", "ITEM  3 ", "ITEM  4 ","ITEM  5 " }));
                   add(comboBox1);
    public int getNumber()
    return number;
              public String getText()
                   if (txtField1.getText() == null)
    return "";
                   return txtField1.getText();
         public int compareTo(MyPanel mp)
              return getText().compareTo(mp.getText());
              //return Integer.valueOf( getText() ).compareTo( Integer.valueOf( mp.getText() ) );

  • How to create unique combined fields in Qual table

    Furhther clarification of my prev question:
    Can I make a unique combined field for a Qualified table. If so how?
    How  the unique field option for combine fields in Main table can be enabled?
    This is for MDM5.5 sp4
    Thanks in advance for the help
    -reo

    Hi,
    Please go through this link,
    http://wiki.sdn.sap.com/wiki/display/ABAP/CreationofView+Cluster
    Hope it helps you,
    Regards,
    Abhijit G. Borkar

Maybe you are looking for

  • I can't open, reinstall or uninstall my itunes

    I downloaded iTunes for the 64 bit model a month ago, and it was working fine. But last week, I couldn't open it anymore. I've tried to reinstall and uninstall it but a page always pops up that says "The feature you are trying to use is on a network

  • Out of the box sharepoint online 2013 workflow

    Hi All, I have a workflow that sends a email to a user after creating a new document. Now a want to attach a document to this email but this is not possible with the out of the box SharePoint 2013 solution. I use the SP 2010 workflow because I need t

  • How to avoid wordbreak of japanese characters in adobe livecycle designer?

    I am using adobe livecycle designer to design the forms.while giving the japanese characters in the text field the word break occurs and goes to next line since it is multi byte character. I have to avoid it and display the whole word in the single l

  • Can't get the album info into my itunes automatically

    I know the info for the cds i'm adding to my library is available but it won't come up. i have checked consolidate library but still won't work.

  • Total Budget Value

    Hello, i have the following question: In the Tabsheet "Financial Overview" in xRPM there are the fields "total budget" and "yearly budget". I entered a value with cj30 for a project in the ERP System. With the Report RPM_FIN02 this value is transferr