Problem with the primary key

Hi All,
I have a table with the same data repeating 2 times. I mean the rows are depating twice. so now I am creating primary key to the table. It is throwing me an error saying primary key voilation. I will provide the clear scenario.
create table Employee(
ID VARCHAR2(4 BYTE) NOT NULL,
First_Name VARCHAR2(10 BYTE),
Last_Name VARCHAR2(10 BYTE),
Start_Date DATE,
End_Date DATE,
Salary Number(8,2),
City VARCHAR2(10 BYTE),
Description VARCHAR2(15 BYTE)
insert into employee values ('01','Jason', 'Martin', to_date('19960725','YYYYMMDD'), to_date('20060725','YYYYMMDD'), 1234.56, 'Toronto', 'Programmer');
insert into employee values ('02','Alison', 'Mathews', to_date('19760321','YYYYMMDD'), to_date('19860221','YYYYMMDD'), 6661.78, 'Vancouver','Tester');
insert into employee values ('03','James', 'Smith', to_date('19781212','YYYYMMDD'), to_date('19900315','YYYYMMDD'), 6544.78, 'Vancouver','Tester');
insert into employee values ('04','Celia', 'Rice', to_date('19821024','YYYYMMDD'), to_date('19990421','YYYYMMDD'), 2344.78, 'Vancouver','Manager');
insert into employee values ('05','Robert', 'Black', to_date('19840115','YYYYMMDD'), to_date('19980808','YYYYMMDD'), 2334.78, 'Vancouver','Tester');
insert into employee values ('07','David', 'Larry', to_date('19901231','YYYYMMDD'), to_date('19980212','YYYYMMDD'), 7897.78,'New York', 'Manager');
insert into employee values ('06','Linda', 'Green', to_date('19870730','YYYYMMDD'), to_date('19960104','YYYYMMDD'), 4322.78,'New York', 'Tester');
insert into employee values ('08','James', 'Cat', to_date('19960917','YYYYMMDD'), to_date('20020415','YYYYMMDD'), 1232.78,'Vancouver', 'Tester')
insert into employee values ('07','David', 'Larry', to_date('19901231','YYYYMMDD'), to_date('19980212','YYYYMMDD'), 7897.78,'New York', 'Manager');
insert into employee values ('06','Linda', 'Green', to_date('19870730','YYYYMMDD'), to_date('19960104','YYYYMMDD'), 4322.78,'New York', 'Tester');
Now the table is with 10 columns
ID FIRST_NAME LAST_NAME START_DAT END_DATE SALARY CITY DESCRIPTION
01 Jason Martin 25-JUL-96 25-JUL-06 1234.56 Toronto Programmer
02 Alison Mathews 21-MAR-76 21-FEB-86 6661.78 Vancouver Tester
03 James Smith 12-DEC-78 15-MAR-90 6544.78 Vancouver Tester
04 Celia Rice 24-OCT-82 21-APR-99 2344.78 Vancouver Manager
05 Robert Black 15-JAN-84 08-AUG-98 2334.78 Vancouver Tester
06 Linda Green 30-JUL-87 04-JAN-96 4322.78 New York Tester
07 David Larry 31-DEC-90 12-FEB-98 7897.78 New York Manager
08 James Cat 17-SEP-96 15-APR-02 1232.78 Vancouver ester
Creating Primary key to the table
"ALTER TABLE employee PRIMARY KEY ( ID, First_Name, Last_Name, Start_Date, End_Date,
Salary, City, Description );"
I am getting primary key voilation error
IS THERE ANY WAY TO CREATE PRIMARY KEY ON THE TABLE WITH OUT DELETING THE DATA?
iS IT POSSIBLE CREATING PRIMARY KEY BY USING 'GROUP BY' FUNCTION OR ANY OTHER FUNCTIONS?
Edited by: user11872870 on Sep 23, 2010 5:41 PM

user11872870 wrote:
Actually there is a small mistake in the question. The table is having the data as
ID FIRST_NAME LAST_NAME START_DAT END_DATE SALARY CITY DESCRIPTION
01 Jason Martin 25-JUL-96 25-JUL-06 1234.56 Toronto Programmer
02 Alison Mathews 21-MAR-76 21-FEB-86 6661.78 Vancouver Tester
03 James Smith 12-DEC-78 15-MAR-90 6544.78 Vancouver Tester
04 Celia Rice 24-OCT-82 21-APR-99 2344.78 Vancouver Manager
05 Robert Black 15-JAN-84 08-AUG-98 2334.78 Vancouver Tester
06 Linda Green 30-JUL-87 04-JAN-96 4322.78 New York Tester
07 David Larry 31-DEC-90 12-FEB-98 7897.78 New York Manager
08 James Cat 17-SEP-96 15-APR-02 1232.78 Vancouver ester
05 Robert Black 15-JAN-84 08-AUG-98 2334.78 Vancouver "NULL"
06 Linda Green 30-JUL-87 04-JAN-96 4322.78 New York "NULL"
There is a null in the duplicate data.....
As there is NULL in the data It is not allowing me to add the primary key to the table.....
I am just looking if there is any other way to create primary key with the same data....the reason for the null not allowing you to have unique records is because null means "unknown". I could go into this in more depth but....
...again - we need to ask, why do you have linda green and robert black in there twice.
if you really do need those two extra rows, then create another column with a unique ID using a sequence and make that the primary key. a primary key uniquely identifies a row. for this data I don't see any reason whatsoever to create a composite key like you are attempting.
by trying to make the entire row a primary key it is clear your understanding is severely lacking.

Similar Messages

  • Problem with the volume keys on my keyboard.

    Hey everybody,
    I have a problem with the volume keys on my keyboard. This started a couple days ago and I can't seem to figure out how to fix it. When I press the volume up or down buttons, the graphic appears on the screen as it normally would, but has no effect on the volume of the sound coming out of my speakers.  Therefore, the only way to change the volume of music or whatever I am listening to is to use the volume control within the program/website itself (itunes, youtube, etc.) Even changing the volume on the volume icon at the menu bar on top of the screen does nothing.  If anyone has an idea of how to go about solving this issue, I would greatly appreciate it. Thanks!

    First look into the Preference > Sound > Outpur whether internal Speakers are choosen.
    The only Preference to delete I can discover is com.apple.systempreferences.plist in your home Library folder. You can try to move it out to the desktop for example, not to loose all your settings. Restart and see whether the problem still persists. If you don't know how to do this here some Terminal (Applications > Utilities) commands. Enter them by copy and paste followed by <enter>
    mv ~/Library/Preferences/com.apple.systempreferences.plist ~/Desktop/
    restart
    to get it back:
    mv ~/Desktop/com.apple.systempreferences.plist  ~/Library/Preferences/
    confirm with "y" if you are asked to replace this file.
    marek

  • I have a new hard drive and itunes and my computer (windows XP) no longer recognise my ipod. I also had the problem with the registry keys not being present but this has now been fixed. However i can no longer link my ipod up with itunes.

    When I first tried itunes with my new hard drive there was the problem with the registry keys but something also flagged up about needing a signed driver. Is this anything to do with why Itunes and my computer no longer recognises when my ipod is linked up? Whatever i try under 'devices' my ipod is never available to sync up. If anyone can help I would be most grateful.

    Thanks for your reply. Unfortunately this has not worked. I didn't have quicktime to begin with so I don't know if that makes a difference? After following the instructions, I get the "registry keys missing" problem appear again (which I've subsequently fixed again) and then when I connected the ipod I got the following message - 'Device driver software was not successfully installed'.
    I've tried windows update but this doesn't do anything as '...the service is not running'.
    Any suggestions?

  • DBMS_CDC find only the columns that are changed along with the primary key in the table

    Hello,
    We are having a requirement to find the change data in the production environment.
    We are planning to use the DBMS_CDC utility.
    But for  example in the create change table 1 picked emp_id,ename, address, salary,dob.
    I have a sample data of
    empid
    ename
    address
    salary
    DOB
    1
    test1
    24 test street
    2000
    20-Jan-98
    2
    test2
    25 test street
    2500
    15-Aug-97
    if ename for empid 1 is changed to test1_test3 from test1.
    My CDC is capturing  the values in the old and new values in the 5 columns.
    But i need to get only the empid (primary key of the source table) and the ename column as only that's been updated not the rest of the 3 columns.
    Can i accomplish this.
    Please advice.

    Hello,
    Thanks for the information.
    but if i change the change table  then i will miss the other columns right?
    I want to get the columns( empid and ename) only if ename is changed. i.e when ever any column in emp table changes i need to get all the columns where the data is changed along with the primary key columns empid.
    Is there any way i can tweak the parameters so that i can achieve this or is there any other way using the cdc i can get this data.
    Thanks

  • Problem with Sting Primary Key

    I have probleme with Sting Primary Key
    when i create new row
    System.out.println("is new:" + acct.getEntityState());
    show 1 - this row is not new
    why?

    Hi,
    I was unable to reproduce this behavior on OWM 10.1.0.8. It appears that you have a SR open for this issue, so I would suggest to continue with that process.
    Regards,
    Ben

  • Bug: problems with the Escape key

    Hi all,
    In an attempt to get around real estate problems, I set my Dell 24" monitor in portrait mode. Logic 8 behaves as it should most of the time. However, there appears to be a problem with the Escape key. Most of the time, the Tools menu doesn't appear until you mouse out of the editing areas (eg into the menu area above the piano roll).
    Clearly, Logic should just take its resolution and screen dimensions from the OS but there appears to be a problem in extreme portrait mode.
    I'll report this but wanted to check that I'm not being an absolute and total plonker first. Anybody confirm this behaviour?
    Thanks!
    Pete

    that sounds like a memory issue. have you tried reorganizing memory?

  • Problem with a primary key when creating a new record in Forms

    My table has a field - MDD_KEY - that is a primary key. It is updated from a sequence with a before-insert database trigger. I know this works properly as the primary key was accurately populated when I inserted 1433 records.
    In Forms 6, I have a form based on that table. I have set the mdd_key as a hidden field because I assume it will be entered by the before-insert trigger. However, when I enter data into the table, and then try to save it, I get a FRM-40202: Field must be entered. - followed by - FRM-40222: Disabled item MDD_KEY failed validation.
    If I set DATA Required to no, when I try to save I get an FRM-40600: Record has already been inserted - but no such record exists in the database. I know this record is unique and does NOT exist because I deliberately made it up.
    In the property palatte, the attributes of the field are:
    DATA Data Type Number
    Required Yes
    DATABASE Database Item Yes
    Primary Key Yes
    Query Only No
    Query Allowed Yes
    Query Length 0
    Insert Allowed Yes
    Update Allowed Yes
    Update Only if Null No
    Lock Record No
    I assume that my problem is that with a new record, the form wants to see the MDD_KEY populated before it saves - but that isn't going to happen until the before insert trigger fires in the database. I assume I have to populate that field within forms, but how do I do that without messing up the database trigger/sequence? I will have to load more data directly into the database - so I need the database trigger in place.
    I have not used primary keys before so I am more than a little bit confused about how and when it should be populated when a new record is created in Forms.
    Any help would be appreciated as I cannot enter new data into my form (works well with existing data).
    Thanks
    Glenn

    hi
    if u have any problem using seq then try that statemetn ur block level in ur form
    PRE-INSERT trigger
    select nvl(max(nvl(srno,0)),0)+1 into :srno from tablename;
    Rizwan

  • Problem with varchar2 primary key..

    OWM version 10.1.0.8
    When I am trying to add a column in a version enable table with varchar2 primary key, it fails.
    If primary key is numeric it works.
    See below the test case.
    -- CASE 1. When primary key is number.
    SQL> create table wmtab
    ( wmtab_id number,
    price number,
    title varchar2(80),
    AUTHOR VARCHAR2(10)
    Table created.
    SQL> ALTER TABLE wmtab add (CONSTRAINT PK_kontakt PRIMARY KEY (wmtab_id));
    Table altered.
    SQL> EXECUTE DBMS_WM.EnableVersioning('WMTAB');
    PL/SQL procedure successfully completed.
    SQL> CALL DBMS_WM.BEGINDDL('WMTAB');
    Call completed.
    SQL> ALTER TABLE wmtab_lts add ( FREIGEGEBEN varchar2(1));
    Table altered.
    SQL> CALL DBMS_WM.commitDDL('WMTAB');
    Call completed.
    -- CASE 2. When primary key is varchar2.
    SQL> create table wmtab
    (wmtab_id varchar2(10) constraint wmtab_pk primary key,
    price number,
    title varchar2(80),
    AUTHOR VARCHAR2(10)
    Table created.
    SQL> EXECUTE DBMS_WM.EnableVersioning('WMTAB');
    PL/SQL procedure successfully completed.
    SQL> CALL DBMS_WM.BEGINDDL('WMTAB');
    Call completed.
    SQL> ALTER TABLE wmtab_lts add ( FREIGEGEBEN varchar2(1));
    Table altered.
    SQL> call DBMS_WM.CommitDDL('wmtab');
    call DBMS_WM.CommitDDL('wmtab')
    ERROR at line 1:
    ORA-20199: primary key columns cannot be added/dropped/modified/reordered for
    version enabled tables
    ORA-06512: at "SYS.OWM_DDL_PKG", line 6196
    ORA-06512: at "SYS.LT", line 11930
    ORA-06512: at line 1
    Same problem is reprosucible on OWM 10.2.0.1.
    But its working fine with varchar2 primary key On OWM 10.2.0.4.2/3
    Is there any workaround or we can get patch for 10.1.x.x?

    Hi,
    I was unable to reproduce this behavior on OWM 10.1.0.8. It appears that you have a SR open for this issue, so I would suggest to continue with that process.
    Regards,
    Ben

  • Batch processing problem: Seeing the primary key (id) in the test cases...

    Another problem we seem to be having is how to read the primary key into a base attribute of an entity.
    In batch processing, we may define the "id" as the primary key on the table. We need to get that id and the foreign key ids into the base attributes in the rule set...
    How do we go about doing that?

    Perhaps better, if you could give me a sample xml config with global and one entity. The only attribute in the entity should be the id... The id should be the primary key in both OPA and Oracle...
    The global table in oracle would contain a single column with the global id.
    The child table in oracle would contain 2 columns -> one for the global ref id and one for the child key...
    I think you will find problems.
    As a note we have duct-tape solved this by creating views and making column copies in the views of the child id and then mapping the id in oracle to the duplicate column in the view.
    So our child view contains the child table with the child id repeated twice so that we can map...

  • Keyboard problems with the "z" key

    Hello everyone, I have problems with my "z" key.Recently, it is sufficent to touch the key without pressing to write the z.Unfortunately that happens also when I want to use the "t" or "u" next to it. I hope you can help me with this problem and can tell me what to do.Thanks in advance for your answers (and sorry for my bad english). greetings, bina90

    Try to reset the device by pressing hold of the home and power button for 15-20 seconds and letting of when the Apple logo appears.

  • Problem with capturing Primary Key Index

    Hi
    I am capturing certain tables and in the mean process i observed that all the indexes are getting captured except the primary key index.
    Any Suggestions on this?
    Thanx,
    Suji

    Hi,
    I was unable to reproduce this behavior on OWM 10.1.0.8. It appears that you have a SR open for this issue, so I would suggest to continue with that process.
    Regards,
    Ben

  • Problems with the Period Key

    This may be strange, but when I type a period "." strange thins happen in Mail and Safari! It is as if when typing a period it is like hitting the return key! Forinstance, if I'm typing a web address in on Safari, as soon as I type a period in the address bar, Safari goes and tries to look up the address before I finish.
    Or, in Mail, when I type a period in the body of the message, the cursor moves down a line like I hit the return key. It even happens while I type this message and it ONLY happens with the period key. This is fustrating! Does anyone have ideas as to how to fix this? I have all upgrades installed and my powerbook generally is running great except for this. Help?

    Don't you have the year dim joined with the fact?

  • Problem With Compound Primary Key

    Hello Experts,
      i am facing some probelm with copound primarykey.
      the Probelm is
    i have data base table which has compound primary key  for that one i have created the entity bean(CMP) and primary key of type compound.using this i am able to insert record into databse but for updation i am using
    <b>findbyPrimarykey()</b> method ,for that methos i am passing
    primary key object with compound key values.
    when i am executing this methos it is throwing <b>nosuchobject exception.</b>
    what might be the problem
    any help will be appriciated
    thanks in advance
    With Regds
    Naidu

    Hi,
    Is ur compound primarykey class is something like this?
    public class PrimaryKey implements java.io.Serializable {
          public String id = "";
          public int no = 0;
          //a default constructor is required:
          public PrimaryKey() { }
          // optional constructor fo clients:
          public PrimaryKey(String id, int no) {
               this.id = smsId;
               this.no = no;
          public String toString() {
               return id + "" + no;
         public boolean equals(Object obj) {
              if (obj == null || !(obj instanceof PrimaryKey))
                      return false;
                   else if ((((PrimaryKey)obj).no == no) && (((PrimaryKey)obj).id.equals(id)))
                      return true;
                   else
                      return false;     
          public int hashCode() {
                return id.hashCode() + no ;

  • Problems with concatenated primary key

    Hi all,
    I am trying to create cache groups of single tables. When I create a cache group (using the browser based cache admin tool) for a table that has a single row primary key, there are no problems. After creating the cache group I can go to TTISQL and issue a select statement of that table to see all the rows.
    However if I create a Cache group in the same way for a table that has a concatenated primary key (using two columns), TimesTen does indeed says that the cache group is created, but then when I issue a SELECT statement for that table in TTISQL, I get "0 rows returned".
    What could be going wrong ? Please advice.
    Thanks in advance

    if you describe the cache group in ttIsql (just enter 'cachegroups;' and hit return) what do you see?
    What message do you get back if you load the cache group in ttIsql:
    load cache group <cgname> commit every 100 rows;

  • Problems with the "X" Key ...

    Since quite a while I noted that I real often miss the "X" key when typing a text. I always treated it as my fault (a typo), especially as it works when typing it a second time. But meanhwile I have to say that it only happens with that "X" key and as I never has a wrong letter in my text and just a missing "X", I start wondering whether there is a problem.
    Now I feel like I have read something about a thing like this a while ago. Unfortunatley I cannot remember where ...
    I also have a hard time searching the Discussions due to difficult search arguments (wow, try X and key ...).
    So my question before I going to buy me a new keyboard ... does anybody has the same feeling that the "X" key fails rather often? Or does even somebody know about a know problem?
    Thx for your info on that!

    Does it do it when you are logged into another User account?
    Dave M.
    MacOSG v.2.0 coming April 1, 2010! No fooling! Check it out!
     MacOSG: An Apple User Group  iTunes: MacOSG Podcast  Follow us on Twitter: MacOSG

Maybe you are looking for