473,507 Members | 6,459 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 3780
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 ...
0
2620
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
1433
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...
0
1307
by: David Allison | last post by:
Foriegn Key Required - Yes - no wonder it didnt work. Now they tell me. -- Dave Allison
0
2008
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...
4
1688
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...
2
1157
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...
1
1149
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),...
1
1166
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...
0
7223
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,...
0
7314
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,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.