SQL Datamodeler ddl generation looses foreign keys

My problem is that when I open my relational model, I select generate of DDL selection Oracle 10g as the physical. I can see the list of referential contraints under the Foreign Key tab. I generate once and all is fine, save the model and exit. I then restart the model and go through the same procedure. This time I can still see the entries under foreign keys tab but when I generate there are no foreign key entries. If I select 11g on the generate then they re-appear. Save it and go back in, select 11g and generate and they have gone again. Select 10g and generate and they are back.
This means I cannot use the physical model attributes (users, synonyms etc) because I keep jumping from 10g to 11g generation models.
Any ideas?
Sql Modeler 2.0.0. build 584.

Hi,
I've got exactly this behaviour - and the exact same workaround to fix it. i.e. Save, change Physical to 11g and save again.
Re-open, won't generate some physical parts correctly i.e. fk constraints.
Swap to 10g and regenerate fine.
You may have to import some fks manually from a DDL file into the physical model to make this happen? Modelled ones seem to work?
If there a switch variable in the DM code gone awry?
Nigel

Similar Messages

  • Sql datamodeler: DDL Generation

    Hello
    Can anybody explain the difference between advanced interactive DDL and advanced CL DDL?
    regards Erik

    Erik,
    they should do the same job, difference is explained at the beginning of scripts (see below) - interactive v. command line parameters. The second option is oriented to be executed by other tools.
    Best regards,
    Philip
    -- ODM advanced script with support for
    -- interactive (SQL/Plus or SQLDeveloper)
    -- settings of input parameters for:
    -- start step, stop step, log file and log level (1,2 or 3)
    =========================
    -- ODM advanced script with support for
    -- command line (SQL/Plus only)
    -- settings of input parameters for:
    -- start step, stop step, log file and log level (1,2 or 3)
    -- The script can be executed as follows (all parameters are required):
    -- sqlplus user/passw@name @script_name start_step stop_st log_file log_level
    -- Examples:
    -- sqlplus scott/tiger@orcl @e:\adv_script.sql 0 0 e:\adv_script.log 2
    --

  • Foreign key Mapping based on Data - in SQL Developer Data modeler

    Team
    Do SQL Developer Data modeler supports Foreign Key mapping based on the Data in the Schema rather defined at the DDL ? For e.g if we implement a Objects Relation ship mapping in Data base, we don't define Foreign keys at table creation.
    Toad does this feature through "AUTOMATIC FOREIGN KEYS MAPPING IN TOAD DATA MODELER" more info at (http://toadworld.com/Blogs/tabid/67/EntryId/905/Automatic-Foreign-Keys-Mapping-in-Toad-Data-Modeler.aspx)
    any one know how to implement through some scripts also helps me
    Regards
    Raj

    If you have table PKs defined and the candidate columns match those PK columns, then you can use the Discover Foreign Keys utility. Right mouse over the relational model name (node) in the left browser. It is about half way down the menu. I did a blog post about it last week on kentgraziano.com.

  • SQL Developer Data Modeler not drawing foreign key relationships

    I'm having trouble with SQL Developer Data Modeler when I importa a DDL that has foreign keys. I export DDL files from SQL developer and choose various subsets of files. Sometimes Data Modeler will not recognize a foreign key if I include say a dozen files in the DDL file, but it will if I include just a few. Worse, even if the foreign key is recognized, sometimes it is not drawn in the Data Modeler and I have no way to make it be drawn. To be specific, I import a file containing the DDL for just two tables -- I see the foreign key! I import a file containing the DDL for a dozen tables including the two, I don't! Is there something I am not understanding about when Data Modeler will draw foreign keys or is the tool simply quite buggy?
    Much thanks!
    -ttamon

    Hi Philip,
    I believe I have isolated the problem. Apparently if a field is named "FOREIGN..." it interferes with the tool recognizing foreign keys. Try to import a DDL file containing the following text:
    CREATE TABLE "SAMPLE"."SAMPLE_ONE"
    (     "ID" VARCHAR2(255 CHAR) NOT NULL ENABLE,
         "VALUE" VARCHAR2(255 CHAR),
         PRIMARY KEY ("ID")
    TABLESPACE "SAMPLE_DATA" ;
    CREATE TABLE "SAMPLE"."SAMPLE_TWO"
    (     "ID" VARCHAR2(255 CHAR) NOT NULL ENABLE,
         "FOREIGN_NAME" VARCHAR2(255 CHAR),
         PRIMARY KEY ("ID")
    TABLESPACE "SAMPLE_DATA" ;
    CREATE TABLE "SAMPLE"."SAMPLE_THREE"
    (     "ID" VARCHAR2(255 CHAR) NOT NULL ENABLE,
         "VALUE" VARCHAR2(255 CHAR) NOT NULL ENABLE,
         "ALT_ID" VARCHAR2(255 CHAR),
         PRIMARY KEY ("ID")
    TABLESPACE "SAMPLE_DATA" ENABLE,
         CONSTRAINT "FK6DF8294F2288190D" FOREIGN KEY ("ALT_ID")
         REFERENCES "SAMPLE"."SAMPLE_ONE" ("ID") ENABLE
    TABLESPACE "SAMPLE_DATA" ;
    You will discover the foreign key is not recognized or drawn! Now, if you swap the location of the third table (put it up first) everything works fine. This is how I discovered the problem, various subsets would work, others would not. To confirm the problem is with the field named "FOREIGN_NAME" use the DDL as specified above but change the first letter in the word "FOREIGN" to something else, and it will recognize the foreign key. Looks like a bug to me (took me about 4 hours to isolate this!). I am using Oracle SQL Developer Data Modeler version 2.0.0 Build 584.
    -ttamon

  • SQl*Modeler - foreign key amendment error

    SQl*Modeler 2.0.0 Build 584 (Windows)
    Oracle 10.2.0.4 Solaris
    If I change an existing foreign key to simply change the delete rule (from say CASCADE to RESTRICT) it changes in memory just fine. If I generate the DDL the change has happened and I get the expected DDL.
    However, I then save the model, exit SQL*Modeler, start SQL*Modeler and check the foreign key the change has been lost.
    I can workaround this by changing the name of the foreign key and the change is saved correctly. Feature ?
    Ian

    Hi Ian,
    I logged bug for that.
    You can use foreign key dialog to do that change without need to change the name - just double-click on FK line or presentation in the browser.
    Philip

  • PRIMARY KEY-FOREIGN KEY 관계 찾기(MASTER TABLE CONSTRAINT 정보 찾는 SQL)

    제품 : ORACLE SERVER
    작성날짜 : 2003-06-19
    PRIMARY KEY-FOREIGN KEY 관계 찾기
    =================================
    PURPOSE
    이 자료는 MASTER TABLE CONSTRAINT 정보를 찾는 SQL이다.
    Explanation
    SCOTT의 EMP table의 Foreign Key와 부모 제약 조건을 찾으려면
    다음의 질의문을 사용하여 찾을 수 있다.
    SQL> alter table dept add constraint dept_pk primary key (deptno);
    Table altered.
    SQL> alter table emp add constraint emp_dept_fk foreign key(deptno)
    references dept(deptno);
    Table altered.
    SQL> select c.constraint_name as "foreign key",
    p.constraint_name as "referenced key",
    p.constraint_type,
    p.owner,
    p.table_name
    from dba_constraints c, dba_constraints p
    where c.owner = 'SCOTT'
    and c.table_name = 'EMP'
    and c.constraint_type = 'R'
    and c.r_owner = p.owner
    and c.r_constraint_name = p.constraint_name;
    foreign key referenced key C OWNER TABLE_NAME
    EMP_DEPT_FK DEPT_PK P SCOTT DEPT
    Example
    none
    Reference Documents
    <Note:1010844.6>

    I don't have intimate knowledge of SQL Server, but to me, your code seems reasonable. I guess there is some "fine point" (a bug?) to using self referenceing foreign keys in SQL Server. It doesn't seem plausible that the error originates with the driver, unless it's a very intelligent kind of driver.
    A "Gordian Knot" kind of solution to your problem is to ask whether you really need the foreign key constraint in the db schema. Is the table used by something other than your EJB? Anyway, putting logic responsible for the correct functioning of your EJB into the db schema is often a bad practice, as it makes the code harder to understand, maintain, port etc.

  • 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

  • FOREIGN KEY CONSTRAINT의 MASTER TABLE을 REFERENCE하는 TABLE 찾기

    제품 : SQL*PLUS
    작성날짜 : 2003-12-17
    FOREIGN KEY CONSTRAINT의 MASTER TABLE을 REFERENCE하는 TABLE 찾기
    ================================================================
    Master table 이 dept2일 때, 이 테이블을 참조하는 table들을 찾는 SQL
    select x.table_name "reference table"
    from
    (select distinct r_constraint_name,table_name
    from all_constraints
    where constraint_type='R' ) x, all_constraints a
    where a.table_name = 'DEPT2'
    and x.r_constraint_name = a.constraint_name;

  • Find foreign key which are able or not

    Same as the topic ~ how can I find all the able/unable foreign key/contraints inside a database ? Using TSQL

    Hello,
    Please try the scripts provided on the following resources:
    http://blog.sqlauthority.com/2009/07/17/sql-server-two-methods-to-retrieve-list-of-primary-keys-and-foreign-keys-of-database/
    http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/
    http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • SQL Developer Data Modeler - Relation to Foreign Key Generation

    SQL Developer Data Modeler 2.0.0 Build 584.
    I am having trouble with Relations to Foreign Keys when Forward Engineering a Relational Model from a Logical Model.
    First of all, the Naming Standard is not applied to the Foreign Keys when I perform the Engineer to Relational Model.
    So I right click on the Relational Model from the Browser and Apply Naming Standards to Keys and Constraints.
    I uncheck everything but Foreign Keys.
    Now, Foreign Keys are named according to my Naming Standards.
    However, this process also performs renames on the Column Foreign Keys even though I specifically unchecked that option.
    This appears to be a BUG in the software and I haven't found a way around it.
    I tried using {column} instead of {ref column} in the Naming Standard Template for Column Foreign Key, but that simply resulted in renaming my columns to "{column}".
    Please confirm and/or let me know of any work-around for this.
    Thanks,
    Dan

    Hi Philip,
    Thanks for the reply.
    Is this recorded as a bug to be addressed in the future?
    Should I submit this problem via Oracle Support?
    The other work-around I came up with is to override every Relation name in the Logical Model with the name I want to use in the Relational Model.
    When the Relational Model is Engineered, this becomes my Foreign Key name.
    Of course, this is not how I want to do things, so I am hoping for a bug fix someday.
    Regards,
    Dan

  • New SQL Developer Data Modeler : name of attributes of foreign key

    Hi,
    with designer the name of column of foreign key was the " short name of entity/table master" + "_" + "the name of column attribute of the master table" .
    Instead in the sql developer D.M. the system uses directly the name of the column/attribute of the master table and if the name exists in the slave table it uses a number to distinguish them .
    So, if i have a table with short name gp and a primmary key id and a slave table with even a column id ,
    with the D.M i'll have in the slave table a column named id2; in the designer instead the new column is gp_id .
    Is possible to have the same behavior of designer even in the SQL Developer Data Modeler ?
    Regards
    Gianpaolo Giliberto

    Hi Gianpaolo,
    the columns of foreign keys are generated without the short name of master tablehow do you define that short name? Table and column have property "Abbreviation" - short name should be set there. You need also to set naming templates in "General Options>Naming Standard>Templates". Templates will be used when foreign key is created or you can apply them in Table dialog or for whole relational model using pop-up menu in the browser.
    no foreign key index is generated on foreign key columns I assume, you want it for DDL generation only - this is controlled in "General Options>DDL"
    Regards,
    Philip

  • Code generation - foreign key relationships

    I'm using the code/descriptor generation tab to generate classes from existing tables. It offers an option of choosing which relationships to generate, but seems to miss out some of the defined foreign key relationships in the database.
    I have three tables, CLIENTS, TXNS and REG
    The following constraints are defined in my database:
    TXN Primary Key: (TXN_ID)
    CLIENTS Primary Key :CLIENT_ID, TXN_ID)
    CLIENTS Foriegn KEy : TXN_ID references TXNS
    REG Primary Key: CLIENT_ID, TXN_ID
    REG Foreign Key: CLIENT_ID, TXN_ID references CLIENTS
    I select these three tables and choose generate classes and descriptors for selected tables. When the "Choose Relationships to generate" screen comes up, it only shows me the CLIENTS<-->TXNS relationship, but not the REG<-->CLIENTS relationship, even though the database foreign key constraints all look as though they've been defined in similar ways.
    thanks for any help.

    Hi Matt,
    I'm not surprised that you have an issue with this. One bugbear I have with Gateway is that for some reason the designers don't think any context beyond the immediate preceding navigation node is important. They don't support this within the same service,so it's hardly likley to work in a service reference.
    I may be wrong but I don't think GW is OData compliant in this respect. If I have the navigation path /blindservice/FromHereSet(1)/ToAPoints(22)/ToBPoints, it's rather restrictive to say I cannot see the initial key of '1' in the path when I am trying to resolve 'ToBPoints'. If that value - where I started - is key to the context, I have to know it.
    Currently the only way to access this context is to embed the 'key history' in the intermediate entities, i.e. /blindservice/FromHereSet(1)/ToAPoints(1,22)/ToBPoints. In my view that is corrupting the URl to suit the limitations of the SAP OData implementation. What's even more confusing/frustrating is that the technical request context appears to be able to store the stacked navigation keys but doesn't make use of this design. 
    I feel your pain
    Ron.

  • Foreign key errors in sql plus

    Hello, im pretty new to sql and i am stuck on a project in my database management class and i was wondering if anyone can help us out. I don't know if it would be easier to send what i've done or just post the error so if anyone could help it will be appreciated.
    This is one part of the sql
    CREATE TABLE PREREQUISITE_T
         (COURSECODE                VARCHAR2(10)NOT NULL,
         PREREQUISITECODE          VARCHAR2(20),
    PRIMARY KEY (COURSECODE),
    PRIMARY KEY (PREREQUISITECODE),
    FOREIGN KEY (COURSECODE) REFERENCES COURSE_T(COURSECODE),
    FOREIGN KEY (PREREQUISITECODE));
    INSERT INTO PREREQUISITE_T VALUES ('23131', '3213');
    INSERT INTO PREREQUISITE_T VALUES ('23541', '4213');
    INSERT INTO PREREQUISITE_T VALUES ('23251', '3413');
    INSERT INTO PREREQUISITE_T VALUES ('56131', '3513');
    INSERT INTO PREREQUISITE_T VALUES ('75431', '3613');
    INSERT INTO PREREQUISITE_T VALUES ('45631', '3813');
    INSERT INTO PREREQUISITE_T VALUES ('65461', '3913');
    INSERT INTO PREREQUISITE_T VALUES ('45351', '5413');
    the error i get is
    ERROR at line 1:
    ORA-02298: cannot validate (STUDENT.SYS_C003016) - parent keys not found
    It works fine without the primary keys but when i put in foreign keys it is all messed up. If there a a tutorial or anyone could take a look at the rest of the code i can send it out. Any help is appreciated.

    probably u had given the column value not exists in the reference table.
    see the example
    create table tst(x number ,y number);
    alter table tst add constraints pk_x primary key(x);
    create table tst1(x number, y number);
    alter table tst1 add constraints fk_x foreign key(x) references tst(x);
    SQL> insert into tst values(&x,&y);
    Enter value for x: 1
    Enter value for y: 2
    old 1: insert into tst values(&x,&y)
    new 1: insert into tst values(1,2)
    1 row created.
    SQL> /
    Enter value for x: 2
    Enter value for y: 3
    old 1: insert into tst values(&x,&y)
    new 1: insert into tst values(2,3)
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> insert into tst1 values(&x,&y);
    Enter value for x: 2
    Enter value for y: 1
    old 1: insert into tst1 values(&x,&y)
    new 1: insert into tst1 values(2,1)
    1 row created.
    SQL> /
    Enter value for x: 5
    Enter value for y: 6
    old 1: insert into tst1 values(&x,&y)
    new 1: insert into tst1 values(5,6)
    insert into tst1 values(5,6)
    ERROR at line 1:
    ORA-02291: integrity constraint (SHFLDEV.FK_X) violated - parent key not found

  • PRIMARY KEY(MASTER)를 REFERENCE하는 FOREIGN KEY 찾는 SQL

    제품 : ORACLE SERVER
    작성날짜 : 2004-03-12
    PRIMARY KEY(MASTER)를 REFERENCE하는 FOREIGN KEY 찾는 SQL
    ========================================================
    $sqlplus sys/manager(SYS user 로 login 함)
    sql> select c.name constraint_name
    from dba_objects a,
    cdef$ b,
    con$ c
    where a.object_name = 'TABLE_NAME'
    and a.object_id = b.robj#
    and b.con# = c.con#
    /

    Hello again,
    May be I was not clear enough.
    Scenario 1: We use the master-detail form as is with the default oolbar. In this case, the user can insert the detail records one by one without needing the primary-foreign key value since this is handled by default.
    Once we save the form (commit_form), I use the pre-insert trigger to get the master block primary key generated from the sequence and since the detail block key is copied from this value, both are saved correctly and it is the end of the story.
    Scenario 2: As explained in the initial post, the user will populate the detail records one by one by clicking on the -INSERT DETAIL- button and hence has a window where he can insert the detail info and then be brought back to the master-detail form every time he enters a new detail record.
    The problem here is that I can't generate the primary key for the master block since the client has the following requirement:
    The user can always change his mind and not complete, meaning save the form, his process
    As such, the key should be generated in the last step before Commit.

  • Foreign Key Error script Generation

    here is
    CREATE table script
    create table employee_history
    (empl_id_hist number,
    empl_name varchar2(20)
    alter table employee_history
    add constraint emp_TO_empHIST foreign key (empl_id_hist)
    references employee (empl_id);
    Create table employee
    (empl_id number,
    ename varchar2(20));
    some empl_id_hist values not in Master table employee.
    now Foreign Key disabled.
    for checking not valid empl_id_hist ids
    I am trying to generate a script like this using Dynamic SQL.
    select unique empl_id_hist from employee_history
    where empl_id_hist not in (select empl_id from employee);
    but i am getting same Column empl_id_hist (instead of empl_id ) in Subquery too
    i.e
    select unique EMPL_ID_HIST from employee_history
    where EMPL_ID_HIST not in (select EMPL_ID_HIST from employee);
    DECLARE
    CNT NUMBER := 0;
    V_SQL_STR VARCHAR2(255);
    v_col_name VARCHAR2(255);
    v_ind CHAR(1);
    v_sql_where VARCHAR2(255);
    CURSOR C1 IS
    SELECT DECODE(c.position, 1, b.table_name, ' ') MASTER_TAB,
    DECODE(c.position, 1, a.table_name, ' ') CHILD_TAB,
    DECODE(c.position, 1, a.constraint_name, ' ') constraint_name,
    c.column_name colname
    from dba_constraints a,dba_constraints b, dba_cons_columns c
    where a.status = 'DISABLED'
    AND a.constraint_type = 'R'
    AND a.constraint_name = c.constraint_name
    and a.r_constraint_name = b.constraint_name (+)
    order by b.table_name, a.table_name, c.position;
    CURSOR c2(cons_name VARCHAR2) IS
    SELECT column_name FROM User_Cons_Columns
    WHERE constraint_name = cons_name
    ORDER BY column_name;
    BEGIN
    FOR R1 IN C1 LOOP
    v_col_name := '';
    BEGIN
    FOR r2 IN c2(r1.constraint_name) LOOP
    cnt := cnt + 1;
    IF cnt <= 1 THEN
    V_ind := 'y';
    V_SQL_sTR := 'SELECT UNIQUE A.'||R1.colname ||' FROM ' ||R1.CHILD_TAB ||' A' || chr(10);
    V_SQL_STR := V_SQL_STR ||'WHERE A.'||R1.colname ||' NOT IN ';
    V_SQL_STR := V_SQL_STR || '(SELECT B.'|| R1.colname ||' FROM ' || R1.MASTER_TAB ||' B);' ||chr(10);
    V_COL_NAME := V_COL_NAME || R2.COLUMN_NAME ||',';
    v_Sql_where := 'WHERE A.'||R2.COLUMN_NAME ||' = B.' || R2.COLUMN_NAME ||chr(10);
    ELSE
    v_ind := 'n';
    v_Sql_where := v_Sql_where || 'AND A.'||R2.COLUMN_NAME ||' = B.' || R2.COLUMN_NAME ||chr(10);
    V_COL_NAME := V_COL_NAME || R2.COLUMN_NAME ||',';
    END IF;
    END LOOP;
    v_sql_where := v_sql_where ||');';
    cnt := 0;
    END;
    IF v_ind = 'y' THEN
    DBMS_OUTPUT.PUT_LINE(V_SQL_sTR);
    ELSIF v_ind = 'n' THEN
    v_sql_str := '';
    v_col_name := SUBSTR(v_col_name,1,LENGTH(v_col_name) - 1) || '';
    V_SQL_STR := 'SELECT UNIQUE '|| V_COL_NAME ;
    V_SQL_STR := V_SQL_STR || ' FROM ' || R1.CHILD_TAB || ' A'|| CHR(10);
    V_SQL_STR := V_SQL_STR || 'WHERE NOT EXISTS ( '||CHR(10);
    V_SQL_STR := V_SQL_STR || 'SELECT 1 FROM ' ||R1.MASTER_TAB ||' B';
    DBMS_OUTPUT.PUT_LINE(V_SQL_STR);
    DBMS_OUTPUT.PUT_LINE(V_SQL_WHERE);
    DBMS_OUTPUT.PUT_LINE('');
    END IF;
    v_ind := '';
    END LOOP;
    END;
    thanks in advance

    That's because with this cursor
    CURSOR c2(cons_name VARCHAR2) IS
    SELECT column_name FROM User_Cons_Columns
    WHERE constraint_name = cons_name
    ORDER BY column_name;You assume that the column names are the same in both tables. You will need to read from user_cons_columns twice, once with the fk constraint name, once with the pk constraint name.
    SQL> create table parent (id number constraint parent_pk primary key) ;
    Table cr&eacute;&eacute;e.
    SQL> create table child (child_id number,
      2                      constraint child_fk1 foreign key (child_id)
      3                      references parent (id)
      4                     ) ;
    Table cr&eacute;&eacute;e.
    SQL> select
      2     a.column_name as parent_column_name,
      3     b.column_name as child_column_name
      4   from
      5     user_cons_columns a, user_cons_columns b
      6   where
      7     a.constraint_name = 'PARENT_PK'
      8     and b.constraint_name = 'CHILD_FK1'
      9     and a.position = b.position
    10   order by
    11     a.position ;
    PARENT_COLUMN_NAME             CHILD_COLUMN_NAME
    ID                             CHILD_ID

Maybe you are looking for