Hi
Ihave two tables class,and students table as following
sql>desc class
Name Null? Type
----------------------------------------- -------- ----------------------------
CLASS_ID NOT NULL NUMBER(4)
CLASS_NAME VARCHAR2(100)
SEAT_NUMBER NUMBER
STUD_ID NUMBER
SQL> desc students
Name Null? Type
----------------------------------------- -------- ----------------------------
STUD_ID NOT NULL NUMBER(4)
STUD_NAME NOT NULL VARCHAR2(50)
BIRTHDATE DATE
ADDRESS VARCHAR2(100)
GENDER VARCHAR2(7)
GRADE NUMBER
STUD_PHONE_NUMBER NUMBER
stud_id is primary key in students table ,and it's added to the class table to make relationship
Iwant to add a foreign key(stud_name ) to table class so I did the following commands:-
sql> alter table class add foreign key(stud_name)references students(stud_name);
error:-
ORA-00904: "STUD_NAME": invalid identifier
SQL> alter table class add (constriant fk_students)foreign key(stud_name)references students(stud
_name);
error:-
ORA-01735: invalid ALTER TABLE option.
Ihave though the problem from primary kry constraint ,so I dropped stud_id column from class table ,and then runned the previous command again but same error getted (.ORA-01735: invalid ALTER TABLE option).
any help please
thanks in advance.