Join sorted on 2 tables, not a foreign key

Hello

I have two tables:

BookAuthor
-------------
number surrogateid
AuthorName varchar
number bookid

Books
-------------------
number bookid
BookTitle varchar
other columns

I want to make some kind of query to join on the two tables where the query arguments are: rangefirst and: rangelast for 2 authornames, where I want to catch all bookauthors authorname between implicit, sorted, and then join the table books to fetch the booktitle and bookid and the authorname, and authornames which are the same also sort the product join by booktitle to the Books table.

I hope it's possible!

NOTE: there no foreign key relationship, so if a line of BookAuthor bookid value that does not exist in the table of books, I don't want a line into the product.

And what kind of evidence do I need on each table.

Thank you
Andy

You need clues if your table is large enough and you select only a few records in the table.

If the create index case bookid on tables.

Once the data are joined, you have no clue to the order.

G.

Tags: Database

Similar Questions

  • ORA-02266: permit to unique/primary keys in table referenced by foreign keys

    Hello
    I'm trying to delete data from a table by dropping a partition. I've identified all the child tables by running the following command.

    Select "select count (*) from ' |" table_name |' where employee_id = 100; »
    of dba_constraints
    where constraint_type = 'R '.
    and r_constraint_name in
    (select constraint_name from dba_constraints
    where constraint_type in ('P', 'U') and table_name =' EMPLOYEE);


    "SELECTCOUNT (*) OF | TABLE_NAME | "WHEREEMPLOYEE_ID_ID = 100; »
    -----------------------------------------------------------------------------------------------
    Select count (*) in the PT_ORDERS where employee_id = 100;
    Select count (*) in the PT_DEP where employee_id = 100;
    Select count (*) in the PT_SKILLSET where employee_id = 100;

    I dropped the score for number 100 in all child tables. The count (*) select returns 0 rows for each of the foregoing.

    When I try to run the command on the EMPLOYEE table, below I get ' ORA-02266: unique/primary keys in table referenced by foreign keys enabled.

    Drop partition ALTER table EMPLOYEE EMP_ID_100;

    I don't see why I am unable to give up this partition now because it is data child present in any of the referenced tables. Any suggestions or help on this would be greatly appreciated.

    Thank you.

    RGS,
    Rob

    You must first disable foreign key constraints and delete the partition. Deletion of lines or a fall in childs partitions do not work in this case
    as you have the overall dependence:


    SQL > create table scott.t (x int primary key, int y)
    2 partition by (list (y)
    3 values p_1 (1) partition, partition values p_2 (2))
    4.

    Table created.

    SQL > create table scott.t_c (x int references scott.t (x), int y)
    2 partition by (list (y)
    3 values p_1 (1) partition, partition values p_2 (2))
    4.

    Table created.

    SQL > insert into scott.t values (1,1)
    3 N

    1 line of creation.

    SQL > insert into scott.t values (2,2)
    3 N

    1 line of creation.

    SQL > insert into scott.t_c values (1,1)
    3 N

    1 line of creation.

    SQL > insert into scott.t_c values (2,2)
    3 N

    1 line of creation.

    SQL > commit;

    Validation complete.

    SQL > alter table scott.t_c drop partition p_2.

    Modified table.

    SQL > alter table scott.t drop partition p_2.
    ALTER table drop partition p_2 scott.t
    *
    ERROR on line 1:
    ORA-02266: permit to unique/primary keys in table referenced by foreign keys

    SQL > select constraint_name from dba_constraints
    2 where owner = 'SCOTT' and constraint_type = 'P '.
    3 and table_name = 't';

    CONSTRAINT_NAME
    ------------------------------
    SYS_C0011058

    SQL > select constraint_name from dba_constraints
    2 where owner = 'SCOTT' and constraint_type = 'R '.
    3 and r_constraint_name = "SYS_C0011058";

    CONSTRAINT_NAME
    ------------------------------
    SYS_C0011059

    SQL > alter the constraint to disable scott.t_c table SYS_C0011059;

    Modified table.

    SQL > alter table scott.t drop partition p_2.

    Modified table.

    SQL > alter table scott.t_c enable novalidate constraint SYS_C0011059;

    Modified table.

    I guess you should consider options such as partitioning Referencial (with some restrictions).

    Best wishes
    Dmitry.

  • ORA-02449: unique/primary keys in table referenced by foreign keys

    SQL > create table empinformation
    () 2
    primary key pk_empinformation number (6) 3 forced mobileno
    4 address varchar (100),
    5 salary number (10),
    6 personalid varchar (10) constraints fk_employees_section references employee (emp_id));

    Table created.


    SQL > drop table empinformation;

    ORA-02449: unique/primary keys in table referenced by foreign keys

    solution

    This error happens when the foreign key of a table is referenced by the primary key of the other table.

    If you want to remove the table had refernce key then, you must
    need to remove this table with the foreign key is referenced.

    or

    SQL > drop table EMPLOYEE CASCADE CONSTRAINTS;
    Deleted table.

    This will remove the table parent without droping the child table.

    Published by: Ritesh Singh October 3, 2011 14:04

  • A table with two foreign keys

    Hi all

    I need to create a table (mytable) filled from 2 different tables, for example, table1 and table2

    When the rows of the table (mytable) comes from the first table (table1) columns in mytable (foreign key to the second table) are nulled, when they come (foreign key) column in the second table (table2)
    the first table) are cancelled as well.

    In terms of performance, architecture is valid, in other words, create a foreign key 2 on mytable and consequently, (the composite foreign key in this table are null according to whether they belong to the first or the second table)?

    Thanks in advance for any help

    I hope to clear

    As promised,

    mhouri.world > create table p as select * from all_users;
    
    Table created.
    
    mhouri.world > alter table p add constraint p_pk primary key (user_id);
    
    Table altered.
    
    mhouri.world > create table c (user_id references p, name varchar2(30));
    
    Table created.
    
    mhouri.world > select min(user_id),max(user_id) from p;
    
    MIN(USER_ID) MAX(USER_ID)
    ------------ ------------
               0           72                                                       
    
    mhouri.world > insert into c (user_id, name) values (0, 'test without index');
    
    1 row created.
    

    Thanks to the autonomous operation I simulates the effect of two users working on the same parent/child table

    (a) first of all, without any index covering the FK on the child table

    (b) second with a function based index on the FK column (note the desc clause in the definition of the index)

    (c) and finally with an index b-tree on the FK columns

    case (a)

    mhouri.world > declare
      2  pragma autonomous_transaction;
      3  begin
      4  delete from p where user_id = 72;
      5  commit;
      6  end;
      7  /
    declare
    *
    ERROR at line 1:
    ORA-00060: deadlock detected while waiting for resource
    ORA-06512: at line 4 
    
    mhouri.world > rollback;
    
    Rollback complete.
    

    case (b)

    mhouri.world > create index fbi_c_fk on c (user_id desc);
    
    Index created.
    
    mhouri.world > insert into c (user_id, name) values (0, 'test with fbi index');
    
    1 row created.
    
    mhouri.world > declare
      2  pragma autonomous_transaction;
      3  begin
      4  delete from p where user_id = 72;
      5  commit;
      6  end;
      7  /
    declare
    *
    ERROR at line 1:
    ORA-00060: deadlock detected while waiting for resource
    ORA-06512: at line 4 
    
    mhouri.world > rollback;
    
    Rollback complete.
    

    case (c)

    mhouri.world > create index btree_c_fk on c (user_id);
    
    Index created.
    
    mhouri.world > insert into c (user_id, name) values (0, 'test with b-tree index');
    
    1 row created.
    
    mhouri.world > declare
      2  pragma autonomous_transaction;
      3  begin
      4  delete from p where user_id = 72;
      5  commit;
      6  end;
      7  /
    
    PL/SQL procedure successfully completed.
    

    Only the index b-tree covered with success the threat of the deadlock in key foreign unidexed

    Best regards

    Mohamed Houri

  • Not getting foreign key fields not filled in datacontrol palette for EJB app

    Hello

    I am quite new FAD and EJB. I developed an application jdeveloper with levels of JSF and EJB. (I use jdeveloper 10.1.3.5)
    For the database to the default human resources database is used. I created the entities for the table EMPLOYEES and DEPARTMENTS.
    I also created a session bean and a data control to the session bean.
    I'm having a JSF page that receives all the details of a new employee and insert into the database (i.e. persistEntity)
    But the constructor used in the data control palette is not filling the MANAGERID and DEPARTMENTID, fields that are
    the foreign key constraints for table and EMPLOYEES by result while trying to make persistent entity
    with automatically filled fields, an error message is thrown.
    If I've used ADF BC instead of the EJB then I could fill all the fields including MANAGERID and DEPARTMENTID.
    Is it possible to have two fields text Manager and Department in the jsf to insert the details of the employee with EJB as a model?.
    If possible how to bind the values of these fields to the entity used in EJB object.


    Kindly need your ideas on this.

    Thank you
    Guna.

    Hello

    How you use MANAGER_ID and department_id fields, they also flush long (or another digital type), or you don't have them mapped to the entity, something like this

    ....
    @ManyToOne
    private Employee manager; // this by default uses the column named MANAGER_ID
    @ManyToOne
    private Department department; // this by default uses the column named DEPARTMENT_ID
    ....
    

    If you have mapped them (which is the right path), when you create an employee, you must set these attributes to the persistence of the entity, using employee.setManager (manager) and employee.setDepartment (department). Then, foreign keys filled automatically by your persistence provider (Toplink).

    If you use data controls, it's a little different process to define the Manager and the Department, but you should take a look at this tutorial http://www.oracle.com/technology/obe/obe11jdev/ps1/ejb/ejb.html, it will answer many of your questions hopefully.

    Pedja

  • Master detail form can not insert foreign key

    Hello

    I Master detail form, in the data block master, I Header_ID primary key and it is generated through trigger on the main table and this field is found in the data block but is hidden on the Web, this Header_ID is a key in another table, on the form, I created the main form and has also created the good relationship. now, when the new record is inserted, the Header_ID in the main table is filled properly while in the secondary table that goes with the NULL value. I have no idea how to solve this problem, any help will be appreciated

    Rather than use a database trigger, select INSERT before triggering in the basic data block to fill the HEADER_ID.

    In the before INSERT trigger, you'd have a line like:

    select seq.nextval into :MASTER.HEADER_ID from dual;
    

    When you do this in the before INSERT trigger will fill the element in the block MASTER that feeds in turn the question into the DETAILS or blocks.

  • Online syntax to create Foreign key with Alter Table statement

    I am a pretty meticulous reader. That being said, from the 4 texts that I read to start to learn SQL, I do not remember and do more that probably not, find a syntax online for the creation of a CF with the statement alter table.

    Just something I thought while I was reading.

    Is there a such syntax?

    And if so someone can give me direction on my code?

    ALTER table emp4 change employee_id key foreign employees of references (employe_id);

    It gives me the option error invalid alter table.

    Any idea would be appreciated.

    Thank you.

    rp0428 wrote:

    A foreign key is a constraint, you must use ADD CONSTRAINT.

    Thare is more than one way to skin a cat:

    SQL > create table tbl (id number, name varchar2 (10))
    2.

    Table created.

    SQL > alter table tbl adds (foreign key references emp (empno))
    2.

    Modified table.

    SQL > select constraint_name,.
    2 constraint_type
    3 from user_constraints
    4 where table_name = 'TBL '.
    5.

    CONSTRAINT_NAME C
    ------------------------------ -
    SYS_C0021920 R

    SQL > drop table tbl purge
    2.

    Deleted table.

    SQL > create table tbl (id number, name varchar2 (10))
    2.

    Table created.

    SQL > alter table tbl change (foreign key references emp (empno))
    2.

    Modified table.

    SQL > select constraint_name,.
    2 constraint_type
    3 from user_constraints
    4 where table_name = 'TBL '.
    5.

    CONSTRAINT_NAME C
    ------------------------------ -
    SYS_C0021921 R

    SQL >

    SY.

  • Identify the foreign key table

    I have a table that has a few constraints that are foreign keys to other tables (see column FK_ETHNIC below). My naming conventions are consistent so they all start with 'FK_ ". In SQL, how can I find the table that the foreign key column references? I have a process that must find this table and then get all of its columns.
    Thank you!

    CREATE TABLE STU_BASE
    (PK_ID VARCHAR2 (32), sys_guid() by default)
    CONSTRAINT pk_stu_base
    KEY ELEMENTARY SCHOOL
    With the HELP of INDEX TABLESPACE sis_express_index
    STORAGE (INITIAL 524288
    NEXT 524288
    PCTINCREASE 0),.
    STUDENT_ID VARCHAR2 (15).
    Fk_stu_base_ethnic FK_ETHNIC VARCHAR2 (32) CONSTRAINT
    REFERENCES
    Ethnic (PK_ID)
    REMOVE THE NULL VALUE;

    CREATE TABLE ETHNIC
    (PK_ID VARCHAR2 (32), sys_guid() by default)
    CONSTRAINT pk_ethnic
    KEY ELEMENTARY SCHOOL
    With the HELP of INDEX TABLESPACE sis_express_index
    STORAGE (4096 INITIAL
    NEXT 4096
    PCTINCREASE 0),.
    VARCHAR2 (2) ETHNIC,.
    ETHNIC_DESC VARCHAR2 (30),
    STATE_CODE VARCHAR2 (2),
    FEDERAL_CODE VARCHAR2 (2))

    You could do a self-join with CONSTRAINTS (USER, ALL, s/n) views. You can search a constrainttype of 'R' and you can attach it to itself based on the R_OWNER and R_CONSTRAINT_NAME columns.

    For example:

    SELECT r1.owner      AS child_owner
         , r1.table_name AS child_table
         , r2.owner      AS parent_owner
         , r2.table_name AS parent_table
    FROM   all_constraints r1
    JOIN   all_constraints r2 ON  r2.owner           = r1.r_owner
                              AND r2.constraint_name = r1.r_constraint_name
    WHERE  r1.constraint_type = 'R'
    ;
    

    Published by: Centinul on February 16, 2012 15:36

  • Questions about the creation of a foreign key on a table

    Hello @ll,

    during an update of the database, 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 werteartarchiv_pt table referencing werteart.

    Some statistics on the size 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 (apologies for the German error message):

    sqlplus ORA-00604: Fehler auf rekursiver SQL-ebony 1
    sqlplus ORA-01652: Temp-Segment kann nicht um 128 in Tablespace TEMPS00 judgements

    The statement that I used:

    ALTER table werteartarchiv_pt
    Add constraint werteartarchiv_pt_fk1
    foreign key (rail, werteartadresse, merkmale)
    Reference werteart (rail, werteartadresse, merkmale)
    on delete cascade
    at the delayed start can be delayed;

    So, the problem seems to be that Oracle needs a lot of temporary tablespace to generate foreign key and I do not know how and why.

    My questions now are, and I hope that someone is there who can answer all or part of it:

    (1) why Oracle should temporary tablespace to create the foreign key? The foreign key uses the same columns as the primary key.

    is 2 (a) possible to change the statement without using the temporary tablespace?

    2 (b) if it is not possible to avoid the use of temporary storage space, is there a formula how to calculate the necessary temporary tablespace?

    (3) is it possible to modify data in tables while the foreign key is created or is the whole table locked during the process?

    Any help or advice is appreciated.

    Kind regards
    Bjoern

    RollinHand wrote:
    My questions now are, and I hope that someone is there who can answer all or part of it:

    (1) why Oracle should temporary tablespace to create the foreign key? The foreign key uses the same columns as the primary key.

    Because it is data validation to ensure that the foreign key are violated. If you had specified NOVALIDATE ACTIVATE in its creation then the existing data in the table should be checked and the statement must fill out instantly (future data added is enabled by the constraint).

    http://download.Oracle.com/docs/CD/B28359_01/server.111/b28310/general005.htm

    Search for "Enable Novalidate constraint State"

  • Find foreign keys are not indexed

    Hello world

    did anyone out there has a sql script that learns the foreign keys of a table are not indexed?

    I was going to write a sql for it, but then I thought that someone somewhere must have written before...

    DB: 10gR 1 and R2

    Thks

    This sql is courtesy of the asktom.oracle.com site.

    To find the script you find «unindexed foreign keys»

    When you run it, it will generate a report such as:

    SQL > @unindex

    STAT... TABLE_NAME COLUMNS COLUMNS
    ======== ============ =========== ========
    APPLICATION_INSTANCES AI_APP_CODE
    OK EMP DEPTNO DEPTNO

    The * in the first line shows me that I have a foreign key that is not indexed in the APPLICATION_INSTANCES table. Ok in the second row shows me that I have an EMP table with a foreign key indexed.

    column constraint_column format a20 word_wrapped
    column index_column format a20 word_wrapped
    column table table_name format a30 word_wrapped

    Select decode (b.table_name, NULL, ' *', 'ok') status.
    a.table_name, a.columns constraint_column, b.columns index_column
    Of
    (select table_name substr (a.table_name, 1, 30),
    substr(a.constraint_name,1,30) constraint_name,
    Max (decode (position, 1, substr(column_name,1,30), NULL)).
    Max (decode (position, 2, ',': substr (column_name, 1, 30), null)).
    Max (decode (position, 3, ',': substr (column_name, 1, 30), null)).
    Max (decode (4 position ',': substr (column_name, 1, 30), null)).
    Max (decode (position, 5, ',': substr (column_name, 1, 30), null)).
    Max (decode (post, 6, ',': substr (column_name, 1, 30), null)).
    Max (decode (position, 7, ',': substr (column_name, 1, 30), null)).
    Max (decode (position, 8, ',': substr (column_name, 1, 30), null)).
    Max (decode (position, 9, ',': substr (column_name, 1, 30), null)).
    Max (decode (position, 10, ',': substr (column_name, 1, 30), null)).
    Max (decode (position, 11, ',': substr (column_name, 1, 30), null)).
    Max (decode (position, 12, ',': substr (column_name, 1, 30), null)).
    Max (decode (position, 13, ',': substr (column_name, 1, 30), null)).
    Max (decode (position, 14, ',': substr (column_name, 1, 30), null)).
    Max (decode (position, 15', ': substr (column_name, 1, 30), null)).
    Max (decode (position, 16, ',' | columns substr(column_name,1,30), null))
    user_cons_columns a, b user_constraints
    where a.constraint_name = b.constraint_name
    and b.constraint_type = 'R '.
    substr(a.table_name,1,30), substr(a.constraint_name,1,30)),
    (select table_name, index_name substr (index_name, 1, 30) substr(table_name,1,30),
    Max (decode (position_colonne, 1, substr(column_name,1,30), NULL)).
    Max (decode (position_colonne, 2, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 3, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 4, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 5, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 6, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 7, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 8, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 9, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 10, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 11, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 12, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 13, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 14, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 15, ',': substr (column_name, 1, 30), null)).
    Max (decode (position_colonne, 16, ',' | columns substr(column_name,1,30), null))
    of user_ind_columns
    Group of substr (table_name, 1, 30), substr (index_name, 1, 30)) b
    where a.table_name = b.table_name (+)
    and b.columns (+) like a.columns. '%'
    /

  • Lack of integrity of foreign keys

    Hi all

    I have two tables org details, emp

    org details with columns like orgname, year, results Quarter1 quarter 2 quarter 3 quarter 4
    Details of EMP having columns like org, year, emp Quarter1, Quarter2, quarter 3 quarter 4.

    Spread the sheet as datasource and imported to the physical layer.

    CASES1:

    Primary keys are orgname and org in two tables
    Created a foreign key relationship in the physical layer.
    Now, fact table is emp details and Dim table is org details.

    Data are like this:

    Org, details (table)

    OrgName (column)
    ======

    IBM
    Microsoft


    Details of the EMP (table)

    Org (column)
    ===

    IBM
    Microsoft
    Oracle

    I could see the data of individual tables in a physical layer above. He started not violation error. Why?

    Imported in MDB layer and presentation layer. Could also be able to view the data in the web interface, data on IBM and Microsoft only.
    In fact, it should thanks to a violation error in all the layers... but didn't?

    I can't view the data in MDB layer and presentation layer?


    Please answer my questions.


    concerning
    Chandra Khalil.

    DKK

    Well...
    Keys & Foregin keys in the physical layer are necessary to implement the (generally 1:m) relationships between your tables, usually it is the provisions.
    Complex joins in the physical layer is required to implement relationships (like 1:1) and other complex expressions that affect the joints.

    Complex joins mdb layer absorbs joins defined in the physical layer. A single application of complex join is in the global navigation.
    Keys keys & foreign in MDB crash layer physical layer joints. (I have never met such a scenario).

    Above stated are ONLY a few points.
    Vino, who was a good link.

    Mark answers quickly.

    J
    -bifacts
    http://www.obinotes.com

    Published by: 791879 on December 3, 2010 12:20

  • PARTITION BY REFERENCE: ORA-02266 when several relatives of foreign key

    Bubble my problem down to a simple example, imagine providers of satellite TV, their programming packages, their clients and customers linking to packages.  Shouldn't be able to drop all data from a provider in one shot?

    CREATE TABLE suppliers

    (provider_name VARCHAR2 (20) NOT NULL)

    CONSTRAINT providers_pk PRIMARY KEY (nom_de_fournisseur)

    )

    PARTITION BY LIST (provider_name) (PARTITION provider__dflt VALUES (DEFAULT))

    /

    CREATE TABLE programming

    (programming_name VARCHAR2 (50) NOT NULL)

    , provider_name VARCHAR2 (20) NOT NULL

    CONSTRAINT programming_pk PRIMARY KEY (programming_name)

    CONSTRAINT programming_fk1 FOREIGN KEY (nom_de_fournisseur)

    REFERENCES (provider_name) providers

    )

    PARTITION BY REFERENCE (programming_fk1)

    /

    Subscribers of CREATE TABLE

    (subscriber_name VARCHAR2 (50) NOT NULL)

    , provider_name VARCHAR2 (20) NOT NULL

    CONSTRAINT subscribers_pk PRIMARY KEY (subscriber_name)

    CONSTRAINT subscribers_fk1 FOREIGN KEY (nom_de_fournisseur)

    REFERENCES (provider_name) providers

    )

    PARTITION BY REFERENCE (subscribers_fk1)

    /

    CREATE TABLE subscriber_programming

    (subscriber_name VARCHAR2 (50) NOT NULL)

    , programming_name VARCHAR2 (20) NOT NULL

    CONSTRAINT Subscriber_programming_pk

    PRIMARY KEY (subscriber_name, programming_name)

    CONSTRAINT subscriber_programming_fk1 FOREIGN KEY (subscriber_name)

    Subscribers of REFERENCES (subscriber_name)

    CONSTRAINT subscriber_programming_fk2 FOREIGN KEY (programming_name)

    Programming REFERENCES (programming_name)

    )

    PARTITION BY REFERENCE (subscriber_programming_fk1)

    /

    ALTER TABLE SPLIT PARTITION provider__dflt values ("dishnetwork") suppliers

    IN (provider_dishnetwork PARTITION, PARTITION provider__dflt)

    UPDATE INDEX

    /

    INSERT INTO suppliers (provider_name)

    VALUES ("dishnetwork")

    /

    INSERT INTO subscribers (subscriber_name, provider_name)

    VALUES ('john doe', "dishnetwork")

    /

    INSERT INTO programming (programming_name, provider_name)

    VALUES ('top200","dishnetwork")

    /

    ALTER TABLE DROP PARTITION provider_dishnetwork UPDATE INDEX providers

    /

    I have same INSERT in subscriber_programming; the above is sufficient to cause the latter to draw "ORA-02266: unique/primary keys in table referenced by foreign keys enabled". ""  Version information:

    -Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production

    -With options for partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing

    -Linux 2.6.32 - 279.11.1.el6.x86_64 #1 SMP Sat Sep 22 07:10:26 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

    This simple demo is simply representative of course.  Our number of real paintings ~ 60, with hundreds of millions of records in a large number of tables, a tree FK covering several levels of depth, without the partition littered throughout key.  Given that the volume of data, we try hard to avoid executing DELETE, which is why I explore PARTITION migration BY reference.  The problem is not unlike the already-fixed Bug 9329773, but it is slightly different - especially that this variant is not resolved.  If there is no way that such a facility would never fly, you have any suggestions that would not involve changes to application code?  (For example, adding a partition to the tables key column kids won't fly, but I might be able to sell disabling constraints to developers.)

    After much head striking, I found the trick, by https://jonathanlewis.wordpress.com/2006/12/10/drop-parent-partition/ .  The difference of Appendix A is bold: the NOVALIDATE on subscriber_programming_fk2 and the EXCHANGE/CREATE/DROP of programming_e.

    CREATE TABLE suppliers

    (provider_name VARCHAR2 (20) NOT NULL)

    CONSTRAINT providers_pk PRIMARY KEY (nom_de_fournisseur)

    )

    PARTITION BY LIST (provider_name) (PARTITION provider__dflt VALUES (DEFAULT))

    /

    CREATE TABLE programming

    (programming_name VARCHAR2 (50) NOT NULL)

    , provider_name VARCHAR2 (20) NOT NULL

    CONSTRAINT programming_pk PRIMARY KEY (programming_name)

    CONSTRAINT programming_fk1 FOREIGN KEY (nom_de_fournisseur)

    REFERENCES (provider_name) providers

    )

    PARTITION BY REFERENCE (programming_fk1)

    /

    Subscribers of CREATE TABLE

    (subscriber_name VARCHAR2 (50) NOT NULL)

    , provider_name VARCHAR2 (20) NOT NULL

    CONSTRAINT subscribers_pk PRIMARY KEY (subscriber_name)

    CONSTRAINT subscribers_fk1 FOREIGN KEY (nom_de_fournisseur)

    REFERENCES (provider_name) providers

    )

    PARTITION BY REFERENCE (subscribers_fk1)

    /

    CREATE TABLE subscriber_programming

    (subscriber_name VARCHAR2 (50) NOT NULL)

    , programming_name VARCHAR2 (20) NOT NULL

    CONSTRAINT Subscriber_programming_pk

    PRIMARY KEY (subscriber_name, programming_name)

    CONSTRAINT subscriber_programming_fk1 FOREIGN KEY (subscriber_name)

    Subscribers of REFERENCES (subscriber_name)

    CONSTRAINT subscriber_programming_fk2 FOREIGN KEY (programming_name)

    Programming (programming_name) NOVALIDATE REFERENCES

    )

    PARTITION BY REFERENCE (subscriber_programming_fk1)

    /

    ALTER TABLE SPLIT PARTITION provider__dflt values ("dishnetwork") suppliers

    IN (provider_dishnetwork PARTITION, PARTITION provider__dflt)

    UPDATE INDEX

    /

    INSERT INTO suppliers (provider_name)

    VALUES ("dishnetwork")

    /

    INSERT INTO subscribers (subscriber_name, provider_name)

    VALUES ('john doe', "dishnetwork")

    /

    INSERT INTO programming (programming_name, provider_name)

    VALUES ('top200","dishnetwork")

    /

    INSERT INTO subscriber_programming (subscriber_name, programming_name)

    VALUES ('john doe', "top200")

    /

    CREATE TABLE programming_e AS

    SELECT * PROGRAMMING WHERE 0 = 1

    /

    ALTER TABLE programming

    Provider_dishnetwork WITH TABLE programming_e SWAP PARTITION

    /

    DROP TABLE programming_e

    /

    ALTER TABLE DROP PARTITION provider_dishnetwork UPDATE INDEX providers

    /

  • Is a foreign key MUST have a UNIQUE or PK column as a reference?

    First I tried, from what I saw Yes it must be Unique or PK. Secondly, I am pretty sure that I read somewhere where there are PK or unique. Thirdly, I checked oradocs and other pages, the thing ends, I owe an answer

    Constraint foreign key (also called a constraint referential integrity) designates a column as a foreign key and establishes a relationship between this foreign key and a primary or unique key specified, called the referenced key.


    This implies, but does not explicitly specify that it MUST be a PK or a SINGLE.


    Basically I want a simple yes/no answer just to give me some peace of mind. I don't want to waste any time, but changes to the oracle from time to time, and I'd rather have a confirmation from someone with more knowledge/experience.


    Thank you!

    Yes.

    This same document you are referencing tells you what are the rules for the creation of a foreign key.

    Data integrity

    Foreign key constraints

    Whenever two tables have one or more common columns, Oracle database can apply the relationship between the two tables with a foreign key, also called a referential integrity constraint constraint. The constraint requires that for each value in the column on which the constraint is defined, the value in the other specified that another table and column must match. An example of a referential integrity rule is that an employee may work for only one Department.

    Table 5-2 lists the terms associated with referential integrity constraints.

    Table 5-2 referential integrity constraint conditions

    Term Definition

    Foreign key

    The column or set of columns included in the constraint definition that refers to a key that is referenced. For example, the department_id column employees is a foreign key that refers to the department_id column of departments .

    Foreign keys can be described as several columns. However, a composite foreign key must refer to a primary or unique key with the same number of columns and the same types of data.

    The value of the foreign keys can be either the primary or unique key value referenced or be null. If any column of a composite foreign key is null, then the portions not null the key do not match any corresponding part of a parent key.

    Referenced key

    The unique key or the primary key of the table referenced by a foreign key. For example, the department_id column departments is the key referenced to the department_id column of employees .

    Table dependent or child

    The table containing the foreign key. This table is based on the values present in the primary or unique key referenced. For example, the employees table is a child of departments .

    Referenced or the parents table

    The table that is referenced by the foreign key of the child table. It is the key to this table reference that determines whether specific inserts or updates are allowed in the child table. For example, the departments table is a parent of employees .

    The first three terms defined in the table EXPLICITLY State references to the 'core' or 'unique' keys to the parent.

    The doc also refers to the Application Developer Guide:

    Maintaining the integrity of the data in Database Applications

    Foreign key references a primary key by default

    If the list of columns is not included in the REFERENCES option when you set a FOREIGN KEY constraint (simple or composite column), then Oracle database assumes that you want to reference the primary key of the specified table. You can also explicitly specify the columns to reference the table parent in parentheses. Oracle database checks automatically to check this list of column refers to a primary or unique to the parent table key. If it isn't, an informative error is returned.

    That the entire paragraph is as explicitly as it gets.

    No list of columns? Oracle then checks for a primary key.

    There is a list of columns? Then Oracle 'control to verify this list of column made reference to a primary or unique key'...

  • Add the foreign key refers to a different schema

    Hello

    We have a database with schemaA and schemaB and we use a data model for schemaA with SQL Data Modeler.

    Our data model is based on SchemaA and we do not want add schemaB or create subview in our current model for schemaB since our dev team do not want schemaB in the model

    We have created a synonym in tableB schemaB shcemaA after granting select them, references to schemaA

    We have added a foreign key on tableA in referencing TableB on schemaB schemaA.

    for example. Add ALTER table tableA foreign constraint key(column-name) references tableB(colum-name)

    So far so good.

    But if we try to produce the DDL for tableA it has not provided the ALTAR of the foreign key that is based on shcmeaB

    We know that we cannot add foreign key on dblinks.

    How can I get the Modeler DDL from SQL data for tableA, including the foreign key

    We appreciate the answers

    Kind regards

    Zafar

    Hi zak,.

    We have created a synonym in tableB schemaB shcemaA after granting select them, references to schemaA

    We have added a foreign key on tableA in referencing TableB on schemaB schemaA.

    You can do it in the database because TableB exists in the database and DB knows its definition, including the existing constraint of PK/UK.

    This is the same model of data Modeler - you must have the definition of the table referenced in order to create the FK that refer to the constraint of PK/UK.

    As it works now (we can change it) you can have modeled for SchemaA and ModelB for SchemaB. Then, you can drag & drop tableB form the Navigator to the diagram of the ModelA and TableB there will exist as an object remote read-only, you can use to create the FK.

    With the help of subviews, DDL generation and configurations of reports, you can display the dev team than objects that they want to see - on the charts in generated DDL and reports.

    Philippe

  • Impdp replace with foreign keys

    I tried an impdp with table_exists_action = replace

    ORA-39120: table 'TABLENAME' may not be truncated, the data will be ignored. Error is:

    ORA-02266: permit to unique/primary keys in table referenced by foreign keys

    If I ADD instead of REPLACE, it will get new records, it also registers changed or deleted?

    actually what I need is to retrieve data of a schema in a database to another database nightly:

    System / * DIRECTORY = EXPORT schemas = SCHEMA_NAME table_exists_action = replace network_link = logfile = LOG.log DB_LINK

    I added this setting

    exclude the = REF_CONSTRAINT

    He took care of my errors replace it with...

    I don't like the constraints I just need the data...

Maybe you are looking for

  • White on the screen of the monitor

    Most of the games I have installed in the system Windows 7 when I run it starts to a black screen and keep black go forever. I do physical reboot by pressing the button. What I notice is the monitor power LED is orange, which means no signal is sent

  • Linksys ac1200 iptv

    Hello I just changed my router to a linksys ac1200, updated its firmware and entered my country. For some reason any now my IPTV does not work.Iptv uses HTTPS and port 8080 See you soon

  • How to view the list of available fonts, and if there are duplicates?

    I can enumerate in my control panet, but he can't find anywhere that I can list and see and example!  I have too many other duplicate how do you recommend deliting copies? * original title - more information on the issue of fonts *.

  • How do I can't scan photos to my computer

    7280 HP all in One, operating system Windows 7, no error message, it has never scanned on my computer.

  • IP in Windows 7

    What is IP?