Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: foreign Key creation SQL help needed!
"Tony!" <none_at_none.com> wrote in message
news:6o6hpv8qtupf0u3vimbj6e6tatc3qecl08_at_4ax.com...
> This is for an SQL class homework assignment.
> ..Now that that's out of the way :)
<thanks for saying this>
> I did the first two problems, but when I try to create the foreign key
> (which I believe is what I need to do to acheive the above) I got an
> error that the column type is incompatable with the referenced column
> type. ((The order# column in orders is Number))
>
> I ended up doing...
>
> _______________
>
> ALTER TABLE SCOTT.HOMEWORK
> MODIFY COLB NUMBER;
>
> ALTER TABLE SCOTT.HOMEWORK
> ADD CONSTRAINT COLB_ORDERS_ORDER#_FK
> FOREIGN KEY (COLB)
> REFERENCES SCOTT.ORDERS (ORDER#)
> ON DELETE CASCADE;
>
> __________________
>
> But I wonder if I was somehow supposed to make it work with the colB
> still being varchar2 type..
It would seem to me that if the requirement is for a foreign key, then what you are saying is that the two properties represented by the two columns are in fact the same thing. Thus a model that has them as different data types is in general incorrect. Ergo I'd give you full marks for the conversion, though you don't show your proof that colb is still in the PK.
-- Niall Litchfield Oracle DBA Audit Commission UkReceived on Fri Oct 24 2003 - 02:57:31 CDT
![]() |
![]() |