Problem with the primary key

Hi all
I have a table with the same data repeat 2 times. I mean that the lines are depating twice. so now, I create a primary key for the table. He throws me an error saying voilation key primary. I'll give you the clear script.

create table employee)
ID VARCHAR2 (4 BYTE) NOT NULL,
First name VARCHAR2 (10 BYTE),
VARCHAR2 (10 BYTE) last_name,
START_DATE DATE,
End_date DATE,
Number (8.2) of salary.
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', 'Program');
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');


The table is now with 10 columns

ID FIRST_NAME LAST_NAME START_DAT END_DATE SALARY CITY DESCRIPTION
---- ---------- ---------- --------- --------- ---------- ---------- ---------------
Jason Martin 25 July 96 01 25 July 06 1234.56 Toronto programmer
02 Alison Mathews 21 March 76 February 21, 86 6661.78 Vancouver Tester
03 James Smith December 12, 78 March 15, 90 6544.78 Vancouver Tester
04 Celia rice 24 October 82 21 April 99 2344.78 Vancouver Manager
Robert Black 05 January 15, 84 8 August 98 2334.78 Vancouver Tester
Linda Green 06 July 30, 87 January 4, 96 4322.78 tester of New York
Manager of New York 07 David Larry 31 December 90 February 12, 98 7897.78
08 James Cat 17-AUG-96 April 15 02 1232.78 ester of Vancouver


Create a primary key for the table

"Employee to ALTER TABLE PRIMARY KEY (ID, First_Name, Last_Name, start_date, end_date,
Salary, city, Description); »

I get error voilation primary key

IS IT POSSIBLE TO CREATE THE KEY PRIMARY ON THE TABLE WITH ON THE DELETION OF THE DATA?
Is IT POSSIBLE CREATING PRIMARY KEY USING 'GROUP BY' FUNCTION or OTHER FUNCTIONS?

Published by: user11872870 on September 23, 2010 17:41

Primary key columns cannot contain NULL values. If you tried to create a primary key constraint, you will get an error like this:

ERROR at line 1:
ORA-01449: column contains NULL values: cannot alter to NOT NULL

However, you can add a unique constraint by doing something like the following:

ALTER TABLE test ADD CONSTRAINT test_unq UNIQUE (column1, column2);

I still wonder why you take the approach you take. I have a vague feeling that're missing us the key pieces of information to recommend the correct solution.

Tags: Database

Similar Questions

  • Problem with the primary key and indexes

    Hi all

    I'm looking a mess on one of our main tables.
    One of the developers here added an index on 3 columns in the table, thinking that it would speed up (not noticing that it had not a PK).

    Subsequently another developer has noticed there do not have a primary on key. So they added a touch of primry on the single column.

    The problem is that now the index created on 3 columns is bein used as the primary key index. As when the primary key is created a new index was not created.

    Is there anyway to get rid of this index/change it correct?

    This table is related to many many other tables, so when we tried to remove the index we could not due to the primary key and foreign key violations with other tables.

    Thanks in advance

    Oracle, as you found, is quite capable to use a column enformce multi index a single column primary key, as long as the pk column is the leader in the index. This should not cause performance issues for a search of PK and if the three indexed columns are often selected only may benefit from these types of queries.

    The only way to change that now, would be to drop all CF, drop and add the PK constraint and then add all the FK constraints. A long time and potentially dangerous (if you miss to add back of the FKs) endeavour. Certainly not worth the risk in my opinion.

    John

  • Problems with the primary key of the query string

    Moving from asp to php, to work with David Power's book: The Essential Guide to Dreamweaver CS4 with CSS, AJAX, and PHP.  Recycling of my brain, so starting from scratch in the learning process.

    Everything was going perfectly until I tried to add the primary key of a record in a query string.  I compared my code with the example code for the book, and everything matches.  When previewing the page in my browser and hover over the link which must pass the main code on the next page, the query string does not appear correctly.  It shows user_id = but no figure shows, as it is supposed to.  www.webpage.com/update_user.php?user_id=

    Here is my code: (Please note, <>have been removed, as I was unable to find a way view the code in the correct way here (copy/paste was doesn't work do not, nor insert syntax))

    ? PHP {?}

    ? PHP echo $row_listUser ['family_name'];? PHP echo $row_listUser ["FirstName"];?

    ? PHP echo $row_listUser ['username'];?       ? PHP echo $row_listUser ["admin_priv"];?

    a href = "update_user.php? user_id =? php echo $row_listUser ['user_id'];?" "Edit / has

    a href = "delete_user.php? user_id =? php echo $row_listUser ['user_id'];?" ' Delete / has

    ? PHP} while ($row_listUser = mysql_fetch_assoc ($listUser));?

    Any ideas that could help me understand why this part does not in particular would be greatly appreciated.  Writing to the database worked perfectly, I see that there are numbers in the database as user_id, and it is defined as my primary key in the configuration database.  Such a simple process that is causing me headaches!

    Thank you

    You have the code to request a copy in your folder:

    $query_listUser = 'SELECT user_id, username, first_name, family_name, admin_priv from users ORDER BY family_name ASC';

    $listUser = mysql_query ($query_listUser, $connSCFDIR) or die (mysql_error ());

    $row_listUser = mysql_fetch_assoc ($listUser);

    $totalRows_listUser = mysql_num_rows ($listUser);

    $query_listUser = 'SELECT username, first_name, family_name, admin_priv from users ORDER BY family_name ASC';

    $listUser = mysql_query ($query_listUser, $connSCFDIR) or die (mysql_error ());

    $row_listUser = mysql_fetch_assoc ($listUser);

    The $listUser table will contain the results of the second query, which does not include the field user_id. delete the redundant code.

  • Problems with the product key

    I have a mac book pro which has a partition with windows 7 pro (I SOUL, in the way that you need to restore the computer whenever you need to use the window). I installed fusion 3 for both systems without having to restart. I deleted the partition and tried to reinstalled the window. now, I have a problem with the product key, what can I do?

    Hi Lumareli,
     
    What is the error you get when you enter the product key?
     
    If you have difficulties to activate Windows 7, open the Windows Wizard of Activation in Windows 7 to use the phone and activate Windows:
     
    Try this and wait for a real person and explain what happened:

    a. Click Start, then in the Find box type slui.exe 4
    b. press enter on your keyboard.
    c. Select your country.
    d. Select the telephone activation option, then call and hold to a real person.
     
    Aziz Nadeem - Microsoft Support

    [If this post was helpful, please click the button "Vote as helpful" (green triangle). If it can help solve your problem, click on the button 'Propose as answer' or 'mark as answer '. [By proposing / marking a post as answer or useful you help others find the answer more quickly.]

  • I have problem with the escape key

    I have the problem with the ESC key... is sometimes from time to time I press my ESC key on my labtop that he would open to the top of my Start menu... there at - it a config that I can turn it off?  Sometimes I play computer game it just annoying someone help please (I'm using Windows vista)

    Hi techon,.

    Welcome to the Microsoft answers site!

    Make sure that you not press CTRL when ESC is crossed.

    Please note the keys CTRL + ESC will bring up Start menu.

    You know, keyboard shortcuts
    http://Windows.Microsoft.com/en-us/Windows-Vista/keyboard-shortcuts

    If the problem persists, you can follow the steps mentioned in the link below:

    Troubleshoot wired keyboards that do not or only the erroneous characters category

    http://support.Microsoft.com/kb/258826

    If the problem persists, please consult the manufacturer of the laptop computer for more information.

    Thank you, and in what concerns:

    Ajay K

    Microsoft Answers Support Engineer

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Problem with the arrow keys in the editor

    Hi, I have problem with the arrow keys in the editor. I don't use arrow in the editor to the bottom and select list (list of table fields, for example). Arrow in the result window or navigator to work normally.
    In the editor, I have problem with SHIFT + left arrow also key.
    Someone at-similar problem? (Developer SQL 1.5.5 with patch)
    Thanks for your reply, Petr

    Could be the old and known problem with accelerators, try:

    Preferences - accelerators - load - default setting

    Hope that helps,
    K.

  • Problem with the function keys

    Hi a few days ago my computer did an automatic update of windows.  This combination of time keyboard shortcuts in my Microsoft Flight Simulator 2004 have changed.  For example, ctrl + any Fkey and shift-several different keys do not work.  Some commands are not options in games keyboard assignments.

    Is there a way to restore my original keyboard settings?

    Thank you...

    Are you sure that Windows Update caused this?

    Restore your computer (by using the system restore) to a previous state - before you install the updates and see if it restores the 'fn' and other features with FS 2004.

    See http://support.microsoft.com/kb/306084 (assuming you are using Windows XP, because the game is compatible with XP and legacy OS)

    If restore fixed the problem with the keys on the keyboard and FS2004, manually install the updates one: after the installation of each update, restart the computer, try to play the game and check if the problem reappears at all.

    This, until you have installed all Windows updates.

    MRI!

  • Problem with the signing key

    Hai guys I have problem with the key signature when signing request l click appears "impossible to ask for signatures until this application with all the necessary powers of signature. any body know this problem? I have send an email to [email protected] no answer not until now.

    * my windows is problem *.

    Thank you

    Well Yes send another.

  • Problems with the shortcut keys, suggestions?

    I have an Asus computer is a portable computer, N56VM. I have problems with my shortcut keys. I can use is no longer the fn + key that usually let me adjust the back of my bright keyboard commands, or my volume (mute, raise/lower the volume), however, my brightness on the monitor shortcuts keyboard still works, and so did my black screen key. Oh, and also, my toggle mouse shortcut is not no longer works. I was looking at the forums, and I upgraded my bios and also reinstalled my ATKPI files and still nothing. I think the problem might have to do with the mechanics of the system, but I am not sure. Any suggestions?

    Hello

    Welcome to the Microsoft community where you can find all the answers related to windows.

    According to the description provided, its looks that you are facing a problem with the system hotkeys, this problem could arise Hotkey readers or the parameters of the system.

    I suggest you day chipset drives and driver hotkey from the manufactures Web site and check if it helps.

    http://www.ASUS.com/notebooks/Multimedia_Entertainment/N56VM/#download

    Note: If the problem persists then I advise you to get in touch with the computer manufacture for further assistance and check if it helps.

    http://support.ASUS.com/ServiceHome.aspx?SLanguage=en

    If you need Windows guru, do not hesitate to post your questions and we will be happy to help you.

  • Problem with the product key of windows 8

    I have problem with my product key of victory 8. I installed it in front of my laptop and it is normal until something goes wrong with my laptop. I decided to reinstall my win 8, and when I put the product key, it does not work. What should I do?

    (1) If you encounter problems with activation, try to reboot / restart your PC a couple of times.
    (2) if it is a new installation of Windows 8 / 8.1 try options refresh or Reset.
    If the two options above do not solve the problem of activation, then try activating the phone.

    How to activate Windows 8 by phone

    Press the Windows key + x then click Run, then type: slui.exe 4
    (Another method: press Windows + r and then type: slui.exe 4)

    Then press the ENTER"" key.

    Select your "country" in the list.

    Choose the option "activate phone".

    Stay on the phone * do not select/press any option * and wait for a person to help you.

    Clearly state your problem to the support person.

    ================= Alternatives ===================================

    Microsoft - U.S. support
    http://support.Microsoft.com/contactus/?PID=17655&TID=100109454

    Microsoft - UK support
    http://support.Microsoft.com/contactus/?ln=en-GB

    How and when to contact Microsoft and support Customer Service:
    http://support.Microsoft.com/kb/295539
    Clearly explain your problem to the support person and they will transfer you to the activation service

    How to contact a Microsoft Product Activation Center by phone:
    http://support.Microsoft.com/kb/950929

    To get a list of telephone numbers see method #1

    J W Stuart: http://www.pagestart.com

  • Can not activate Win 8 - reports of problems with the product key

    Hi all

    I have just downloaded 8 Win and tried to upgrade my existing Win 7 Home Premium VM, which I run on VMWare Fusion 5.0.1 on my Intel MacBook Pro 2009. I wasn't able to do the upgrade in place - the installer told me that it was not possible to run Win 8 on this machine. Instead, I created a. ISO file and used to install Win 8 in a new virtual machine. Everything works fine, but I can't activate Win 8. The error message tells me that "something is wrong with the product key" even if I could install Win 8 with the same fine product key.

    I called various hotlines MS today but don't have anything got no solid advice. Am I the only one who experience this issue? Is there something I need to pay attention during installation of the virtual machine to win 8? Is it possible to install a fresh VM with a key product upgrade in the first place? I would appreciate any information you might have on this subject.

    Thank you in advance and Bravo,

    Georg

    Hello

    Had the same problem after installing Win 8 Pro Upgrade on Fusion 5. Follow-up to "How to do a clean install on Windows 8 Pro Upgrade VMWare Fusion" here, problem solved (for now).

    http://www.moosooboo.com/tag/clean-install-on-Windows-8-Pro-upgrade-in-VMware-Fusion/

    Good luck

    JKB

  • Is there a known problem with the quick keys in InDesign CC?

    More specifically, with the quick key to justify the text/paragraphs to the left.

    Shift + command C = works

    SHIFT + R = work order

    Shift + command L = does not work

    Any information would be appreciated.

    Thank you in advance.

    You are on a Mac.

    Open system preferences > keyboard > shortcuts > Services. Go to the Google search and uncheck the box. He would steal your keystrokes at the keyboard.

  • Satellite L850 - 1 H 4 - a strange problem with the FN key

    Hello

    I have a strange problem on my laptop. When I uninstall my PVAT my start "FN" key works, when I install it it s not working not properly. Its market not only the volume key (F9 and F10) without pressing the "Fn", if I want to press F9 or F10 I have to press FN + F9, even with the rest of the buttons.

    When I install PVAT I have to press FN, so I can use my F keys (e.g. F3 to search on the browser tool, alt + f4 - I have to press Fn + alt + f4), and I can't use real functions like mute, disable Touchpad etc. Use the volume keys only. Y at - it a problem if I run my computer without PVAT, this may affect its performance?

    Where could be the problem and can I fix it? I'm with Windows7 x 64, but the laptop was with no OS when I bought it. And there is a problem with this version, I bought its impossible to install the Pakc3 Service, it s with SP1, can be the problem? I put t know what to do... perhaps I run the laptop without PVAT, sounds good, because the buttons work fine without it, but I don't know if it interacts with something else.

    Thanks in advance!

    Its possible to use the function buttons by pressing another button without the use of the fn or FN.
    This option can be changed in the BIOS.

    Go to the BIOS by pressing F2.
    In the BIOS, choose Advanced-> system configuration Options
    Here you should find the option that allows to change the special function keys which allows you to use the function FN or without button Fn button

    By the way: this theme has already spoken here in the forum several times. therefore recommend that you use the advanced search to Forums before posting new thread

  • Satellite P200-10s - problem with the Tilde key

    Hello

    I recently bought my laptop and installed a game (Oblivion) and in this game, we can call the console of the game but I can't call because the key does not work. The Tilde key about 1. I have been googling and noticed that a lot of people with windows vista on laptops have this problem... can someone help me?
    Is it possible that key hangs on the mode full screen?
    (Sorry my English)

    Thanks in advance,
    Francisco

    Hello Francisco

    This game is not known to me, but it will be interesting to know if this game is designed for Windows XP Home edition or Vista operating system. In any case if the same question is noticed by many other users of laptop I don't see any solution here. It seems that the problem is not caused by laptop faulty or something similar. If your laptop works well, you game homepage and see if there is a solution.

    Manufacturers of laptops have noting to do with it.

  • Problem with the primary dns server, get the error "There could be a problem with one or more network adapters on this computer."

    Hello

    I was all of a sudden having problems connecting to my wifi at home. When I was diagnosed, he says cannot communicate with primary dns server. I tried all methods in similar positions, but nothing works. I am also unable to connect to internet with my iphone and the itouch. It's really frustrating, because I've already tried all of your suggestions. I just ran another ' diagnose connection problems and it says the following:
    "There could be a problem with one or more network adapters on this computer." Help, please!
    Thank you!

    Thanks for your help, but I have tried this before. In the end I just unplugged my modem and plugged in again and it worked? I feel a bit silly not to try first.

Maybe you are looking for