473,666 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unable to add foriegn key constaint

1 New Member
hello friends,
i am a beginer.I was unable to add a foriegn key constraint to my NAMES table which refers my EMPLOYEE TABLE

Expand|Select|Wrap|Line Numbers
  1. SQL> desc employee
  2.  Name                                      Null?    Type
  3.  ----------------------------------------- -------- ----------------------------
  4.  FNAME                                              VARCHAR2(10)
  5.  LNAME                                              VARCHAR2(10)
  6.  SSN                                       NOT NULL NUMBER(4)
  7.  ADDRESS                                            VARCHAR2(50)
  8.  SEX                                                VARCHAR2(1)
  9.  SALARY                                             NUMBER(5)
  10.  SUPERSSN                                           NUMBER(5)
  11.  DNO                                                NUMBER(1)
  12.  
  13. SQL> desc names
  14.  Name                                      Null?    Type
  15.  ----------------------------------------- -------- ----------------------------
  16.  NAME                                               VARCHAR2(5)
  17.  NSSN                                               NUMBER(4)
  18.  
  19. SQL> alter table names add constraint nn8 foriegn key(nssn) references employee(ssn);
  20. alter table names add constraint nn8 foriegn key(nssn) references employee(ssn)
  21.                                                  *
  22. ERROR at line 1:
  23. ORA-01735: invalid ALTER TABLE option
Mar 3 '07 #1
2 3796
Dave44
153 New Member
hello friends,
i am a beginer.I was unable to add a foriegn key constraint to my NAMES table which refers my EMPLOYEE TABLE

Expand|Select|Wrap|Line Numbers
  1. SQL> desc employee
  2.  Name                                      Null?    Type
  3.  ----------------------------------------- -------- ----------------------------
  4.  FNAME                                              VARCHAR2(10)
  5.  LNAME                                              VARCHAR2(10)
  6.  SSN                                       NOT NULL NUMBER(4)
  7.  ADDRESS                                            VARCHAR2(50)
  8.  SEX                                                VARCHAR2(1)
  9.  SALARY                                             NUMBER(5)
  10.  SUPERSSN                                           NUMBER(5)
  11.  DNO                                                NUMBER(1)
  12.  
  13. SQL> desc names
  14.  Name                                      Null?    Type
  15.  ----------------------------------------- -------- ----------------------------
  16.  NAME                                               VARCHAR2(5)
  17.  NSSN                                               NUMBER(4)
  18.  
  19. SQL> alter table names add constraint nn8 foriegn key(nssn) references employee(ssn);
  20. alter table names add constraint nn8 foriegn key(nssn) references employee(ssn)
  21.                                                  *
  22. ERROR at line 1:
  23. ORA-01735: invalid ALTER TABLE option

Just remember that a foreign key must reference either a unique key or primary key on another table. (i cant see what your indexes and primary keys are here)

**but in this case the immediate problem appears to be your spelling of the word foreign (not foriegn) ** :)
Mar 3 '07 #2
debasisdas
8,127 Recognized Expert Expert
your problem is poor spelling
use FOREIGN KEY
YOUR PROBLEM WILL BE SOLVED

note:-foreign key refers to a Primary key or at least an Unique field.
Take care in future.
Mar 10 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
632
by: Girish Agarwal | last post by:
Hi All, I have a database consisting of 2 tables. patient_info ( Patient Information ).Looks like lastname VARCHAR(10) fname VARCHAR(10) ssno INT(9) PRIMARY KEY ID INT(4) AUTO_INCREMENT patientins_info ( PatientInsurance Information)
0
2634
by: Girish Agarwal | last post by:
--0-474210375-1058976151=:31789 Content-Type: text/plain; charset=us-ascii Content-Id: Content-Disposition: inline Note: forwarded message attached. __________________________________
1
1438
by: Bob | last post by:
Hi, Does anyone know why forgein key constraints are not enforced when updateing multiple tables using a combination of views and rules? This doesn't seem to be a major problem as I can specify the columns in question as not null and this will produce an ExecInsert error if the data is not present in my insert. However, it seems to me that it would be better to be able to rely on
0
1316
by: David Allison | last post by:
Foriegn Key Required - Yes - no wonder it didnt work. Now they tell me. -- Dave Allison
0
2014
by: Dev | last post by:
Hello all, I have a database system in which i truncate a main table to update the information. I would like to setup some foriegn keys referencing back to that table but am concerned as to how the truncating of the Parent table will effect the keys? Would all I have to do is insure that I vacuum the db after I truncate and repopulate the table? ----------
4
1694
by: irfi | last post by:
Hi, I am a form which has a sub form, The sub form is linked with primary key of main form as a foriegn key in sub form, very basic, In the main form, I have another field which is investor, and in the sub form, I have created investory foreign key, this is the second link between main form and subm form.
2
1167
by: kimtherkelsen | last post by:
Hi, I have developed some software for a PDA in C# (.Net compact framework 2.0) in VS2005. The problem is that I am not able to see the contents of any of the exceptions that are thrown on the device. If I am debugging and an exception occurs, the environment just says "missing resource assembly" when I try to se what it says in the exception. Does anyone have any idea what dll I am missing? The PDA is actually running Windows CE 4.2...
1
1163
by: nads707 | last post by:
i hav following 2 tables n i am able to insert data into the second table having a foriegn key create table Customer_Details( Customer_ID integer primary key, Customer_First_Name varchar(75), Customer_Last_Name varchar(75), Address varchar(100))
1
1174
by: srinivaspnv21 | last post by:
hi every one, plz help me out in setting primary key and foriegn key to tables in sql server 2000 and brief description on it or any article u have plz send me...... waiting for u r replies....... thanking you..
0
8438
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8348
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8863
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7376
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1761
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.