|
-
Still Alive
New to SQL, need some help
Its my first time using SQL and I am having trouble with the ADD CONSTRAINT command. I am trying to add a constraint to a column that refers back to the primary key of the table that the column is in.
Here's what I have:
create table project
(p_id NUMBER(6) constraint project_p_id_pk primary key,
project_name VARCHAR2(30),
client_id NUMBER(6),
mgr_id NUMBER(6),
parent_p_id NUMBER(6),
constraint project_client_id_fk foreign key (client_id)
references client (client_id),
constraint project_mgr_id_fk foreign key (mgr_id)
references consultant (c_id));
alter table project
add constraint project_p_id_fk
foreign key (parent_p_id)
references project (p_id);
I want to make project_p_id refer to p_id, but I'm getting this error
ORA-00904: invalid column name at line 3
line 3 being "foreign key (parent_p_id)"
Oh and here is a line from my assignment saying what we have to do:
"parent_p_id references the same table project. Note that you need to use ALTER statement to create this foreign key."
Anyway I'm sure I have made a simple error or something seein as how this is my first time. Thx fer the help.
------------------
-= SySTeM =-
Athlon 850 | | Asus A7V133A
Radeon 7500| | 256 PC 133 Micron
SoundBlaster XGamer 5.1 | | WD 20gig 7200
LiteOn 16x | |Enlight 7237 300 watt psu
[This message has been edited by spamjedi (edited February 02, 2002).]
||Intel Dual-Core 1.8 GHz||GIGABYTE GA-965P-DS3||EVGA GeForce 8600GTS||
||G.SKILL 2GB||Seagate Barracuda 250GB||PHILIPS 20X DVD±R||COOLER MASTER Centurion 5||
||A64 3000+||Chaintech SK8T800|Radeon 9800 Pro||
||1 gig PC2700||WD 80gig 7200||BenQ 1620 16x4x40x24||XDreamer II||
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|