|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Newbie needs help creating database using SQL+ Worksheet
I'm trying to create my first database using SQL+ Worksheet for a CD collection. My first table, "artist", and 2nd table, "reclable" have only primary keys, no foreign key. The 3rd table, "catelog", is where I get stuck. When using this create statement:
CREATE TABLE Catelog CatNum DECIMAL(4,0) primary key, Title CHAR(50) not null, Genre CHAR(2), foreign key (labelcode) references reclabel, check (CatNum > 0), check (Genre in ('AR', 'BL', 'C', 'JZ', 'P', 'RB', 'RK', 'RP'))) ; I get this error: foreign key (labelcode) references reclabel, * ORA-00904: invalid column name labelcode IS a valid column name in reclabel. When using command: describe * reclabel results are: NAME LABELCODE LABELNAME I don't understand what I'm doing wrong. I have a feeling I'm missing something very basic, but I don't know what it is. Please help before I pull out more hair that I can't afford to lose! Thanking you in advance for your time. Cheryl |
|
#2
|
|||
|
|||
|
Foreign Key
try this...........
create table catelog ( LableCode char(4) not null, CatNum number(4)primary key, Title char(50) not null, Genre char(2), foreign key(LableCode) references Table2_name(reclable) ) / |
|
#3
|
|||
|
|||
|
Thank you so much! That worked.
|
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Newbie needs help creating database using SQL+ Worksheet |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|