Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2012
    Posts
    9

    Unanswered: foreign-key / primary key DNU

    Greetings all,

    I have the following primary table with this basic schema with HEALTH_ID_SEQ as primary key:

    CREATE TABLE "APSOM"."SERVER_CURRENT_HEALTH_CPU_SWAP"
    ( "ENVIRONMENT_ID" VARCHAR2(10 BYTE),
    "SERVER_ID" VARCHAR2(10 BYTE),
    "SWAP_USED_PERCENT" FLOAT(126),
    "SWAP_AVAILABLE" NUMBER(20,2),
    "HEALTH_CHECK_DATETIME" TIMESTAMP (6),
    "EVENT_ID" NUMBER(*,0),
    "AVAILABLE_RAM" NUMBER(7,2),
    "SWAP_USED" NUMBER(20,2),
    "TOTAL_RAM" NUMBER(7,2),
    "HEALTH_ID_SEQ" NUMBER(*,0),
    ...)

    ALTER TABLE "APSOM"."SERVER_CURRENT_HEALTH_CPU_SWAP" ADD CONSTRAINT "SERVER_CURRENT_HEALTH_PK" PRIMARY KEY ("HEALTH_ID_SEQ") DISABLE;

    I have the following secondary table with EVENT_HISTORY_ID as its primary key:

    CREATE TABLE "APSOM"."EVENT_HISTORY"
    ( "EVENT_HISTORY_ID" NUMBER(5,0),
    "EVENT_ID" NUMBER(5,0),
    "EVENT_CATEGORY_ID" NUMBER(5,0),
    "EVENT_DATETIME" TIMESTAMP (6),
    "EVENT_SEVERITY_ID" NUMBER(5,0),
    "HEALTH_ID_SEQ" NUMBER(*,0),
    "HEALTH_ID_FS_SEQ" NUMBER(*,0),
    "HEALTH_ID_TS_SEQ" NUMBER(*,0)
    )

    ALTER TABLE "APSOM"."EVENT_HISTORY" ADD CONSTRAINT "XPKEVENT_HISTORY" PRIMARY KEY ("EVENT_HISTORY_ID")
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS ... ENABLE;

    I am trying to create the HEALTH_ID_SEQ foreign key of the EVENT_HISTORY table connected to the HEALTH_ID_SEQ primary key of the
    CURRENT_HEALTH_CPU_SWAP table:

    ALTER TABLE EVENT_HISTORY
    ADD CONSTRAINT EVENT_HISTORY_SERVER_CURR_FK3 FOREIGN KEY
    (
    HEALTH_ID_SEQ
    )
    REFERENCES SERVER_CURRENT_HEALTH_CPU_SWAP
    (
    HEALTH_ID_SEQ
    )
    ENABLE

    and I am getting an ORA-02270: no matching unique or primary key for this column-list error. If the HEALTH_ID_SEQ field is set as PK in the SERVER_CURRENT_HEALTH_CPU_SWAP table, why would I be receiving this error?? - Any help would be appreciated. -

    Thanks,

    Patrick Q

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Would that be because the PK constraint on SERVER_CURRENT_HEALTH_CPU_SWAP is disabled?
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Sep 2012
    Posts
    9
    That was the cause. I do not know how the Primary Key constraint got disabled. Thanks.

    Patrick Q

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Quote Originally Posted by gikyo12 View Post
    that was the cause. I do not know how the primary key constraint got disabled. Thanks.

    Patrick q
    >alter table "apsom"."server_current_health_cpu_swap" add constraint "server_current_health_pk" primary key ("health_id_seq") disable;
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •