1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Creating a FK

Discussion in 'SQL PL/SQL' started by Tariq Bashir Malhi, Apr 21, 2010.

  1. Tariq Bashir Malhi

    Tariq Bashir Malhi Forum Advisor

    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    80
    I am creating a foreign key between two tables with following command

    Code (SQL):

    ALTER TABLE core_business.cb_insured_person  ADD (
      CONSTRAINT fk_present_prov_cty_cbi
     FOREIGN KEY (present_province_code,present_city_code)
     REFERENCES general_information.cb_city (province_code,city_code) NOVALIDATE);
     
    i have DBA privilege and i am used to do such work, but when i execute above statement i give error of insufficient privilege, how i can resolve this .....

    Code (SQL):
     
    CREATE TABLE CORE_BUSINESS.CB_INSURED_PERSON
    (
      IP_REGION_FO_CODE NUMBER(4, 0) NOT NULL
    , IP_CHECK_DIGIT VARCHAR2(1 BYTE) NOT NULL
    , IP_SERIAL_NO NUMBER(6, 0) NOT NULL
    , EO_CODE NUMBER(6, 0)
    , REGISTRATION_CODE NUMBER(2, 0)
    , TITLE VARCHAR2(5 BYTE)
    , FIRST_NAME VARCHAR2(35 BYTE) NOT NULL
    , OLD_NIC_NO VARCHAR2(13 BYTE)
    , NEW_NIC_NO VARCHAR2(15 BYTE)
    , FAMILY_CODE VARCHAR2(6 BYTE)
    , GENDER VARCHAR2(1 BYTE)
    , RELATIVE_NAME VARCHAR2(35 BYTE)
    , RELATIONSHIP_CODE NUMBER(3, 0)
    , DATE_OF_BIRTH DATE
    , DATE_OF_JOINING_EOBI DATE
    , PRESENT_ADDRESS VARCHAR2(100 BYTE)
    , PRESENT_PROVINCE_CODE NUMBER(2, 0)
    , PRESENT_CITY_CODE NUMBER(5, 0)
    , PRESENT_POST_CODE NUMBER(5, 0)
    , PRESENT_TELEPHONE VARCHAR2(30 BYTE)
    , CONSTRAINT PK_CB_INSURED_PERSON PRIMARY KEY
      (
        IP_REGION_FO_CODE
      , IP_CHECK_DIGIT
      , IP_SERIAL_NO
      )
      ENABLE
    )
    LOGGING
    TABLESPACE "EOBI"
    PCTFREE 10
    INITRANS 1
    STORAGE
    (
      INITIAL 747634688
      MINEXTENTS 1
      MAXEXTENTS 2147483645
      BUFFER_POOL KEEP
    );


    CREATE TABLE GENERAL_INFORMATION.CB_CITY
    (
      PROVINCE_CODE NUMBER(2, 0) NOT NULL
    , CITY_CODE NUMBER(5, 0) NOT NULL
    , NAME VARCHAR2(25 BYTE) NOT NULL
    , AREA_CODE VARCHAR2(6 BYTE)
    , STATUS VARCHAR2(1 BYTE) NOT NULL
    , CREATED_BY VARCHAR2(10 BYTE) NOT NULL
    , CREATED_DATE DATE NOT NULL
    , MODIFIED_BY VARCHAR2(10 BYTE) NOT NULL
    , MODIFIED_DATE DATE NOT NULL
    , DIVISION_CODE NUMBER(5, 0)
    , DISTRICT_CODE NUMBER(5, 0)
    , CONSTRAINT PK_PRV_CTY PRIMARY KEY
      (
        PROVINCE_CODE
      , CITY_CODE
      )
      ENABLE
    )
    LOGGING
    TABLESPACE "EOBI"
    PCTFREE 10
    INITRANS 1
    STORAGE
    (
      INITIAL 81920
      MINEXTENTS 1
      MAXEXTENTS 2147483645
      BUFFER_POOL DEFAULT
    );


    CREATE UNIQUE INDEX GENERAL_INFORMATION.CB_CITY_PK ON GENERAL_INFORMATION.CB_CITY (NAME ASC)
    LOGGING
    TABLESPACE "EOBI_IDX"
    PCTFREE 10
    INITRANS 2
    STORAGE
    (
      INITIAL 65536
      MINEXTENTS 1
      MAXEXTENTS 2147483645
      BUFFER_POOL DEFAULT
    );

    CREATE UNIQUE INDEX GENERAL_INFORMATION.CB_CITY_UK ON GENERAL_INFORMATION.CB_CITY (PROVINCE_CODE ASC, CITY_CODE ASC)
    LOGGING
    TABLESPACE "EOBI_IDX"
    PCTFREE 10
    INITRANS 2
    STORAGE
    (
      INITIAL 65536
      MINEXTENTS 1
      MAXEXTENTS 2147483645
      BUFFER_POOL DEFAULT
    );

     
     
  2. Tariq Bashir Malhi

    Tariq Bashir Malhi Forum Advisor

    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    80
    This issue has been resolved.