HOw to create a foreign key in Derby netbeans 5.0

I am trying to create a primary key in my database/web java application. I am using netbeans 5.0 and java vr5. I have put the following line in the DERBY SQL editor:
ALTER TABLE staff ADD CONSTRAINT staff_fk FOREIGN KEY (staffID) REFERENCES staff (staffID);
this returns Error: staffID is not a colum in Table of VTI skill
However I have got a staffID Column in the table. Is this a BUG in netbeasn 5.0 or am I doing this incorrectly please can anyone show me a way round this problem. Iam suppose to use CMP or something please help.
thanks in advance

ALTER TABLE "staff" ADD CONSTRAINT "staff_fk" FOREIGN KEY ("staffID") REFERENCES "staff" ("staffID");

Similar Messages

  • How to create a foreign key for the table from two different tables?

    Hi All,
    I have a three table like below. In the below table SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK will be having the primary key for NAME column. The same SAMPLE_CONS3_CHECK table also having the primary key for NAME column and forieign key for SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK tables. See the below code 2
    code 1:
    CREATE TABLE SAMPLE_CONS_CHECK
            (NAME VARCHAR2(10),
            SERIES  VARCHAR2(5)
    CREATE TABLE SAMPLE_CONS2_CHECK
            (NAME  VARCHAR2(5),
             MODEL  NUMBER
    CREATE TABLE SAMPLE_CONS3_CHECK
            (NAME  VARCHAR2(5),
             MODEL_NO  NUMBER
            )code 2
    alter table SAMPLE_CONS_CHECK
    add constraint SAMPLE_CONS_CHECK_pk primary key (NAME)
    alter table SAMPLE_CONS2_CHECK
    add constraint SAMPLE_CONS2_CHECK_pk primary key (NAME)
    alter table SAMPLE_CONS3_CHECK
    add constraint SAMPLE_CONS3_CHECK_pk primary key (NAME)
    ALTER TABLE SAMPLE_CONS3_CHECK ADD
    CONSTRAINT SAMPLE_CONS3_CHECK_FK1 FOREIGN KEY
         NAME
    ) REFERENCES SAMPLE_CONS_CHECK
        NAME
    ) ON DELETE CASCADE;
    ALTER TABLE SAMPLE_CONS3_CHECK ADD
    CONSTRAINT SAMPLE_CONS3_CHECK_FK2 FOREIGN KEY
         NAME
    ) REFERENCES SAMPLE_CONS2_CHECK
        NAME
    ) ON DELETE CASCADE;From the above schenario i am able to insert the data to SAMPLE_CONS3_CHECK table. But the parent data is already available in the parent table. The problem is here two different constarints from two different tables. While inserting, it is checking from both the tables whether the parent is exist or not.
    How can i solve this problem? Can anyone halp me about this?
    Thanks
    Edited by: orasuriya on Aug 8, 2009 2:02 AM

    Actually the design is completely incorrect.
    What you say is
    I have
    'foo', 'foo series'
    'foo','foo model'
    'foo',666
    By virtue of table3 referring to both table1 and table2.
    This means you actually need to have 1 (one) table:
    'foo','foo series','foo model', 666
    And the 'problem' disappears.
    Sybrand Bakker
    Senior Oracle DBA

  • How to create a Foreign key relationship between 2 user defined tables...

    Hi Folks,
    I have created two user defined tables... Where in i want to create foriegn key relationship between the 2 tables.... Can anyone guide the step by step procedure to do this scenario...
    Any help would be highly appreciated...
    Thanks

    Hi
    1.  In the 2nd table call the field of the 1st table which is a primary key.
    2.  Give the same field and dataelement name.
    3.  Select that field and then click on the foreign key field icon which is beside Search Help button.
    4. Then give short text, and the 1st table name.
    5. Then in the below box give the 2nd table name and 2nd table field name which you have called from 1st table.
    6. Then click on copy, then u will be able to see Check table name and check table field name beside foreign key table name.
    7. Then again click on copy.
    Regards
    Haritha.

  • How to create a foreign key in dictionary  in dynpro

    actually I have used the method given in one of replies by using the <u><b>ddl</b> scripts</u>.I want to ask whether it really works if yes then plz send me all the commands to be written in the script files  .please do send it urgently

    actually I have used the method given in one of replies by using the <u><b>ddl</b> scripts</u>.I want to ask whether it really works if yes then plz send me all the commands to be written in the script files  .please do send it urgently

  • Questions about creating a foreign key on a large table

    Hello @ll,
    during a database update I lost a foreign key between two tables. The tables are called werteart and werteartarchiv_pt. Because of its size, werteartarchiv_pt is a partitioned table. The missing foreign key was a constraint on table werteartarchiv_pt referencing werteart.
    Some statistics about the sizes of the mentioned tables:
    werteart 22 MB
    werteartarchiv_pt 223 GB
    werteartarchiv_pt (Index) 243 GB
    I tried to create the foreign key again, but it failed with the following error (Excuses for the german error message):
    sqlplus ORA-00604: Fehler auf rekursiver SQL-Ebene 1
    sqlplus ORA-01652: Temp-Segment kann nicht um 128 in Tablespace TEMPS00 erweitert
    The statement I used:
    alter table werteartarchiv_pt
    add constraint werteartarchiv_pt_fk1
    foreign key (schiene, werteartadresse, merkmale)
    references werteart (schiene, werteartadresse, merkmale)
    on delete cascade
    initially deferred deferrable;
    So the problem seems to be, that Oracle needs a lot of temporary tablespace to generate the foreign key and I do not know how much and why.
    My questions now are, and hopefully someone is here, who can answer all or a part of it:
    1) Why does Oracle need temporary tablespace to create the foreign key? The foreign key uses the same columns like the primary key.
    2a) Is it possible to tweak the statement without using the temporary tablespace?
    2b) If it is not possible to avoid the usage of the temporary tablespace, is there a formula how to calculate the needed temporary tablespace?
    3) Is it possible to modify data in the tables while the foreign key is created or is the whole table locked during the process?
    Any help or hint is appreciated.
    Regards,
    Bjoern

    RollinHand wrote:
    My questions now are, and hopefully someone is here, who can answer all or a part of it:
    1) Why does Oracle need temporary tablespace to create the foreign key? The foreign key uses the same columns like the primary key.Because it's validating the data to ensure the foreign key won't be violated. If you had specified ENABLE NOVALIDATE when creating it then the existing data in the table wouldn't need to be checked and the statement should complete instantly (future data added would be checked by the constraint).
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/general005.htm
    Search for "Enable Novalidate Constraint State"

  • Create a foreign key from a field that is part of a mulitple primary key

    Hi,
    i had a table named T_A, with a double primary key : (A,B)
    Then i created a table named T_B with a field : C.
    I want this field T_B.C to take only values that already exist in field T_A.A.
    So i tried to create a foreign key on my field T_B.C, pointing on the field T_A.A : an error message appeared "not possible to create a foreign key on a field that is not a primary key".
    How can i solve this....? If U have any idea, please mail me !!
    THANX very much.

    Add column A as foreign key into the table T_BHow?
    (was the question from the original poster. Adding a column to table T_B that happen to have same name as the corresponding column in table T_A would not allow you to add the foreign key).
    SQL> create table t_a (a number, b number, primary key(a, b)) ;
    Table created.
    SQL> create table t_b(a number, c number, constraint foreign key references t_a(a)) ;
    create table t_b(a number, c number, constraint foreign key references t_a(a))
    ERROR at line 1:
    ORA-02270: no matching unique or primary key for this column-list
    SQL>

  • How to create a block key default for documents created by MIRO?

    Hi All,
    How to create a block key (BSEG-ZLSPR) default for documents created by MIRO?
    Could anyone tell me?
    Thanks
    Gandalf

    HI,
    The payment block--BSEG-ZLSPR can be made defaulted by two  ways.
    Means you want to fix one value all the times for the same ,you have to do the same in Vendor master
    ie in the Vendor Master in the Payment Transactions Selection screen. make the Payment Block you want to be defaulted in MIRO.
    you can do for all vendor master in mass change -- XK99.(LFB1)
    if you are not OK with the Above .then there is another way to do the same
    it is by Screen layout setting in SHD0
    in this enter the Transaction MIRO and create a Transaction variant Z*** and click on create
    and also create a Screen variant in OMLRLIST 
    T code MIRO
    Screen variant name Z**
    Program-SAPLFDCB
    Screen Number 0020
    and create it .
    in creating ---enter the default value in the Payment block and in the varinat just check the box w.content
    KNow in SHd0 add this screen variant for the above Trasaction variant
    and then activate this trasaction variant by going into the tab Standard variants.
    so that when ever you do miro this variant will be called and you can get this payment block defaulted.
    hope so it helps
    Regards
    Anjanna

  • How to create a shortcut key for email ?

    how to create a short key on mac book pro

    You do not say what OS X you are running.  If it is 10.8.3 you simply can have Mail a 4-finger swipe away.
    No short key neccessary?
    If some earlier OS X see >System Preferences>Keyboard>KeyboardShortcuts>ApplicationsShortcuts

  • How to create a account key for application type M ?

    Hi Guys,
    How to create a account key for application type M ? and link the same with
    Gl account.
    thanks.

    Hi
    Please create the account keys or transaction keys in
    SPRO-> IMG-> MM-> Purchasing-> Conditions-> Define Price Determination Process-> Define Transaction/Event Keys
    Thanks & Regards
    Kishore

  • Creating a foreign key constraint on a synonym of table in another schema.

    Hi,
    I am having two user operapps and oper
    owner of table po_vendors is operapps ,i have created a synonym in oper with select permission.
    now i am trying to create a foreign key.
    ALTER TABLE OPS_BR_VENDORS ADD ( FOREIGN KEY (VENDOR_ID) REFERENCES PO_VENDORS (VENDOR_ID));
    the bolded po_vendors is the synonym for the table po_vendors in operapps.
    i am getting the below error message.
    SQL> ALTER TABLE OPS_BR_VENDORS ADD ( FOREIGN KEY (VENDOR_ID) REFERENCES PO_VENDORS (VENDOR_ID));
    ALTER TABLE OPS_BR_VENDORS ADD ( FOREIGN KEY (VENDOR_ID) REFERENCES PO_VENDORS (VENDOR_ID))
    ERROR at line 1:
    ORA-01031: insufficient privileges.
    i have given dba privileges to oper user.
    Please advice.

    1) You cannot create a constraint on a synonym. You have to specify a physical table (i.e. OPERAPPS.PO_VENDORS)
    2) The owner of the OPS_BR_VENDORS table will need to have the REFERENCES permission on the PO_VENDORS table granted directly (not via a role).
    Justin

  • I am unable to create the Foreign key

    Hi,
    I need to create the Foreign key which reffered to composite primary key.
    the following table structure
    Parent table
    DIVISION, PROJECT_NUMBER, COMPETITION_PROJECT_NUMBER, COMPETITIVE_STMT_TYPE, SEQUENCE, CATEGORY, STATEMENT, USER_ID, RECORD_MODIFICATION_DATE
    Here composite primary key columns(DIVISION, PROJECT_NUMBER, COMPETITION_PROJECT_NUMBER, COMPETITIVE_STMT_TYPE, SEQUENCE)
    Child Table
    DIVISION          VARCHAR2 (4)          
    PROJECT_NUMBER          NUMBER (10)COMPETITION_PROJECT_NUMBER     NUMBER (10)          
    COMPETITIVE_STMT_TYPE          VARCHAR2 (2)          
    SEQUENCE     NUMBER (2)          
    CATEGORY          VARCHAR2 (100)     
    STATEMENT     LONG          
    USER_ID     VARCHAR2 (100)          
    RECORD_MODIFICATION_DATE     DATE     
    ALTER TABLE COMPETITION_STMT ADD (CONSTRAINT COMPET_STMT_FK_PROJ_NUM foreign key
              (PROJECT_NUMBER) REFERENCES PROD_COMPET_XREF (PROJECT_NUMBER));
    when i am trying to create foreign key i got this error
    ORA-02270: no matching unique or primary key for this column-list
    this is production issue Please help me.
    Thanks in advance
    Regards
    Kumar.s

    ALTER TABLE PROD_COMPET_XREF ADD (
    CONSTRAINT PROD_COMP_XREF_PK_DPNCPNCT
    PRIMARY KEY
    (COMPETITION_PROJECT_NUMBER, PROJECT_NUMBER, DIVISION, PRODUCT_LOC_INDICATOR)
    When you create a foreign key, it must reference a unique or primary key. The primary or Unique key must consist ONLY of those columns upon which the Primary key is based.
    You must Alter the table and add a Unique key if you want to keep your compsite primary key constraint. The Unique key must be for only the column that your foreign key references. Then try to recreate your foreign key.
    I doubt you will be able to add a foreign key because I suspect you might have multiple rows with the same value for this column based on your composite key; however, if you only intend for the project number to be listed only once and to be unique for each row, then the unique key may work or you may want to revist your primary key on this table. Perhaps you don't need it to be a composite PK???
    If you can't work around that, one thing you can do is build a table based just on PROJECT_NUMBER that contains details about the project number and have other tables reference that. That is, if you have multiple rows with the same project number in that table. You may already have one? Perhaps you can build your foreign key to reference that?

  • How to retrieve the Foreign key information in Oracle

    I want to know how to retrieve the Foreign Key information in Oracle while using SQL Statement?
    I have use three SQL statement to retrieve such information, but the performance is very bad.
    The three SQL Statements are:
    Select constraint_name, r_constraint_name from all_constraints where constraint_type = 'R' and table_name = table1;
    Select column_name from all_cons_columns where constraint_name = cons1;
    Select table_name, column_name from all_cons_columns where constraint_name = r_ccons1;
    Do anyone know another method to retrieve the Foreign Key information which has better performance?

    These sql-statements don't seem very performance intensive. My guess is something is wrong with your database (unless you have millions of constraints). How many constraints do you have? how many concurrent users? What is your dictionary cach hitratio? (other hitratio?) memory problems? other tasks of the computer? is this query the only one being slow? etc.

  • How to create a unique key using two or more attributes?

    how to create a unique key using two or more attributes ?

    The following example illustrate how to create a unique key using two or more attributes/fields
    Scenario: Implementing Unique Key on ManagerID & Location ID in DepartmentEO(Department Table)
    Step#1: Open the Desired Entity Object “DepartmentEO”. Go to Overview tab & Click “General” Finger tab.
    Step#2: Expand “Alternate Keys” section & click “+”.
    Step#3: In the Pop-up wizard, Enter a name for alternate Key “Unique_Manager_X_Location”.
    Step#4: Select the desired attributes/fields from available list & Shuffle to right side.
    Step#5: Now go to “Business Rules” finger tab.
    Step#6: Select “Entity Validators” in the list & click “+” to add a new entity level validation rule.
    Step#7: In the Pop-up, Select “Rule Type” as Unique Key
    Step#8: In the “Rule Definition” tab select the key “Unique_Manager_X_Location”created.
    Step#9: Now go to “Failure Handling” tab, and click the Magnifier Icon .
    Step#10: If the key is not already created then in the “Select Text Resource” Popup, Using the functional design document, Enter display value, Key and Description. And click “Save & Select” Button.
    Step#11: Now Click “OK”.

  • How to Create a Restricted Key Figure in BO Webi Report

    Hi Experts,
    Please tell me How to Create a Restricted Key Figure in BO Webi Report.
    Thanks in Advance.
    Regards,
    Rafi

    Hi,
    1. Define a new measure in the designer.
    2. In the select clause give the reference to the key figure on which restriction to be applied.
    For example
    @Select(Key Figures\Number of Records)
    3. In the where clause, give the MDX expression for the filter to be applied.
    For example
    <FILTER KEY="[0PURCH_ORG].[LEVEL01]">
    <CONDITION OPERATORCONDITION="InList">
    <CONSTANT CAPTION="HAS"/>
    </CONDITION>
    </FILTER>
    Regards

  • How to create a table component dynamically in netbeans 6.0 (JSF 1.2)?

    How to create a table component dynamically in netbeans 6.0 (JSF 1.2)?
    This example http://developers.sun.com/jscreator/reference/techart/2/createTableDynamically.html works only with JSF 1.1.

    Please help my write correct code.
    How to replace this strings for run example?
    rowGroup.setValueBinding("sourceData", getApplication().createValueBinding("#{Page1.tripDataProvider}"));
    staticText1.setValueBinding("text", getApplication().createValueBinding("#{currentRow.value['TRIP.TRIPID']}"));

Maybe you are looking for

  • How do I by default save new documents in a particular folder?

    In OS10.3.9, how do I by default save new documents in a particular folder? I have created a new folder called new docs which I have put in the dock, and would like to save all new documents in that folder... Thanks, Michael

  • File exists but program can't open it

    G'day all. I am trying to port some fortran programs from a True64 environment into Sun v9/SunStudio 11. On the alpha it has no problems, but on the Sun it can't open a file with a name that is only 78 characters long. The Fortran User's guide states

  • Query not considering function based index in oracle 11g

    I have a query which used Function Based Index when run in oracle 9i but when I run the same query without any changes, it does not consider index. Below is the query: SELECT distinct patient_role.domain_key, patient_role.patient_role_key, patient_ro

  • How to create SynBO with  BAPIs from R/3 server?

    Hi, Can I get any documents or links regarding Syncbo creation with BAPIs from another R/3 server. I think I have to create RFC destination for this. The steps for creating RFC destination in Netweaver 2004s is also helpful for me. Also I need the re

  • Declaring private cursors in package header

    Hi. Im tunning a PLSQL package , and im having the following doubt. This package has alot of cursors declared in the package header, but the cursors are private. (called within the package only) Could the public functions from the package have a loss