Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: foreign Key creation SQL help needed!

Re: foreign Key creation SQL help needed!

From: Niall Litchfield <n-litchfield_at_audit-commission.gov.uk>
Date: Fri, 24 Oct 2003 08:57:31 +0100
Message-ID: <3f98db6c$0$254$ed9e5944@reading.news.pipex.net>


"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 Uk
Received on Fri Oct 24 2003 - 02:57:31 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US