var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Oracle FK relationship question
Another quick Oracle question. I created a primary table with a single primary key with the following structure:
Create table SERVERLIST
( "SERVER_ID" VARCHAR2(10 BYTE) ...)
ALTER TABLE "APSOM"."SERVERLIST" ADD CONSTRAINT "XPKSERVERLIST" PRIMARY KEY ("SERVER_ID")
and I created another table with 2 primary keys that I would like to reference the SERVERLIST table
CREATE TABLE "CPULIST"
( "CPU_ID" VARCHAR2(10 BYTE),
"SERVER_ID" VARCHAR2(10 BYTE), ...)
ALTER TABLE "APSOM"."CPULIST" ADD CONSTRAINT "CPULIST_PK" PRIMARY KEY ("CPU_ID", "SERVER_ID")
I tried to create a foreign key relationship with the SERVER_ID field of the CPULIST table to the same field of the SERVERLIST table, and it failed. How can I get this to work??
Turning Point Global Solutions
Well, without more information, your chances are pretty low.
How can I get this to work??
What did you type?
What was the exact error message?
90% of users' problems can be resolved by punching them - the other 10% by switching off their PCs.
You should have posted your SQL*Plus session so that we could see what you exactly did and how Oracle responded. Let my copy/paste be a guide for your future messages.
SQL> create table serverlist
2 (server_id varchar2(10),
3 server_name varchar2(20)
SQL> alter table serverlist add constraint pk_sl primary key (server_id);
SQL> create table cpulist
2 (cpu_id varchar2(10),
3 server_id varchar2(10),
4 freq number
SQL> alter table cpulist add constraint pk_cl primary key (cpu_id, server_id);
SQL> alter table cpulist add constraint fk_cl_sl foreign key (server_id)
2 references serverlist (server_id);