How to compare the DOF of the OWNER. Table_name two DB in a single query?

Hello community,

I am trying to compare the DDL from a table that is located in two databases with the same name and the same pattern:

select my_files.schema_name || '.' || my_files.table_name as table_name
     , case ( select dbms_lob.compare( dbms_metadata.get_ddl(one.object_type, one.object_name, one.owner)
                                     , dbms_metadata.get_ddl(two.object_type, two.object_name, two.owner)
                                     )
                from all_objects  one
                   , all_objects@db_link  two
               where one.object_type = 'TABLE'
                 and one.owner = my_files.schema_name
                 and one.object_name = my_files.table_name
                 and two.object_type = one.object_type
                 and two.owner = one.owner
                 and two.object_name = one.object_name
            )
         when 0 then 'Y'
         else 'N'
       end as ddl_equal_flag
  from my_files;

When I run the query above in SQL Developer, I get results like:

Table-name DDL_EQUAL_FLAG
MY_SCHEMA. TABLE_1THERE
MY_SCHEMA. TABLE_2THERE
MY_SCHEMA. TABLE_3THERE
etc.etc.

But I wonder if it really works... I suspect DBMS_METADATA. GET_DDL returns the DDL of the database where I am connected, regardless of the database link, I used. Is this correct?

And if so, is there another approach that gives me the expected results?

Your help is very appreciated!

Best regards, Yvo

I would not use DBMS_METADATA, but the DBA_TAB_COLUMNS query directly.

Tags: Database

Similar Questions

  • How to compare the content of two Wordpad / documents notebook without reading them line by line?

    How to compare the content of two Wordpad / documents notebook without reading them line by line?

    Hello

    Without this feature is included in the operating system.

    However, you can use your favorite search engine to look for software that needs to perform these tasks.

    WARNING of THIRD PARTY SOFTWARE: Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

    Hope this information helps.

  • How to compare the content of two files so I can delete duplicate records

    I'm trying to clean up several subfolders with duplicates without looking at the details of each record.  Is it possible in Windows XP to compare the content of two files whether they are an exact replica.

    Hi rav42010,

    Follow the steps in the article.

    Description of the tool in Windows XP disk cleanup

    http://support.Microsoft.com/kb/310312

    You can also use third-party app to perform the task using your favorite search engine.

    Note: Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

  • How to find the number of lines executed for a single query in oracle

    Hi all

    I have a query that will return the details according to certain search criteria.
    Here I want to how many lines is performed (as a column) for the given search criteria, including the details of the column table... in a single query.



    Thanks in advance
    Geraldine

    I want all the details and number of rows in table...

    SQL> select ename, job, count (*) over () total
      from emp
     where deptno = 20
    /
    ENAME           JOB                     TOTAL
    --------------- ------------- ---------------
    SCOTT           ANALYST                     5
    SMITH           CLERK                       5
    JONES           MANAGER                     5
    ADAMS           CLERK                       5
    FORD            ANALYST                     5
    
    5 rows selected.
    
  • How to compare the value of two combo

    I have two Combo Box (cbFirst & cbSecond). I want to compare the value that has been selected by the user and according to the result, the output is displayed. In the two combo box, I have provided the value.

    Here is my code:

    var a: number;
    var b:Number;

    function First(evt:Event):void {}
    a = evt.target.value;
    trace (a);
    }
    cbFirst.addEventListener (Event.CHANGE, first);

    function Second(evt:Event):void {}
    b = evt.target.value;
    trace (b);
    }
    cbSecond.addEventListener (Event.CHANGE, second);

    If (a > b) {}

    trace ("more")

    on the other

    trace (b is higher);

    Trace the statement inside the functions work very well and the value correct a & b is printed. But the comparison in the if statement does not seem to work. Could you please help me.

    There is a typing error.  Fix it or delete it:

    var a: number;
    var b:Number;

    function First(evt:Event):void {}
    a = evt.target.value;

    trace (a);
    compareF();
    }
    cbFirst.addEventListener (Event.CHANGE, first);

    function Second(evt:Event):void {}
    b = evt.target.value;
    trace (b);

    compareF()
    }
    cbSecond.addEventListener (Event.CHANGE, second);

    function compareF() {}

    If (a > b) {}

    trace ("more")

    on the other

    trace (b is higher);

    }

  • How to run the procedure which parameter is in a single query

    Hi all

    Here's sinario

    create or repalce procedure proc1 (number, number xyz, sys_refcursor Prefcur abc)
    as
    Start
    ...
    ......
    ... do something...


    end;

    front end, all paramertes came as string...

    'proc1 (1,5,Prefcursor).


    now what I do is that I created an another procedure that accept this string as parameter.

    create or replace procedure proc2 (Vpstring varchar2, Prefcursor to sys_refcursor)
    as
    Start

    execute Vpstring;

    end;



    but it gives me error


    Please help me solve this problem.

    any help appriciated

    It looks like a very strange requirement for me.

    Try like this.

    SQL> create or replace procedure p1(a1 number, a2 number, a3 out sys_refcursor)
      2  as
      3  begin
      4     open a3 for select * from dual where a1 = a2;
      5  end;
      6  /
    
    Procedure created.
    
    SQL> create or replace procedure p2(str varchar2, rc out sys_refcursor)
      2  as
      3     lstr varchar2(100);
      4  begin
      5     lstr := 'BEGIN ' || substr(str,1,instr(str,',',1,2))||':1);' ||' END;';
      6
      7     execute immediate lstr using rc;
      8  end;
      9  /
    
    Procedure created.
    
    SQL> var rc refcursor
    SQL> exec p2('p1(1,1,rc)',:rc)
    
    PL/SQL procedure successfully completed.
    
    SQL> print rc
    
    D
    -
    X
    
    SQL> exec p2('p1(1,2,rc)',:rc)
    
    PL/SQL procedure successfully completed.
    
    SQL> print rc
    
    no rows selected
    
    SQL>
    

    Thank you
    Knani.

  • Compare the content of two equal nested tables

    I'm working on a black box test where I compare the contents of two structurally equal tables before and after executing a script of some. My two tables, MDQ_OLD and MDQ_NEW, are filled with the data in two separate operations.

    The two tables, I'll compare are nested, as you can see in the CREATE TABLE scripts below.

    I tried to use the less-operator sign, but without success.

    I also tried to select data in a type that is % ROWTYPE to my nested tables, but it does not work as well (see the below script in this post).

    Can you please help me on this problem on how to compare the content of two nested tables?

    Run the scripts below to reproduce the problem and be sure to update this post if more information is required.

    -The scripts below-

    Select * from version of v$.

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

    PL/SQL Release 11.2.0.4.0 - Production

    CORE Production 11.2.0.4.0

    AMT for Linux: Version 11.2.0.4.0 - Production

    NLSRTL Version 11.2.0.4.0 - Production

    -First of all, I create my types

    CREATE OR REPLACE TYPE FORCE AS OBJECT MDQ_DETAIL (NUMBER OF MDQ_DETAIL_ID, MDQ_DETAIL_DESC VARCHAR2 (100));

    CREATE OR REPLACE TYPE T_MDQ_DETAIL AS TABLE MDQ_DETAIL;

    -Note that this type contains the table T_MDQ_DETAIL type:

    CREATE OR REPLACE TYPE MDQ_PARENT FORCE AS OBJECT (NUMBER MDQ_ID, MDQ_DETAILS T_MDQ_DETAIL);

    - Then I create two equal nested tables

    CREATE THE NESTED TABLE AS MDQ_PR_OLD STORE MDQ_DETAILS MDQ_PARENT MDQ_OLD TABLE.

    CREATE THE NESTED TABLE AS MDQ_PR_NEW STORE MDQ_DETAILS MDQ_PARENT MDQ_NEW TABLE.

    -Insert test data in the nested tables

    Insert into MDQ_OLD (MDQ_ID, MDQ_DETAILS) Values (1, T_MDQ_DETAIL (MDQ_DETAIL(1,'desc1')));

    Insert into MDQ_NEW (MDQ_ID, MDQ_DETAILS) Values (2, T_MDQ_DETAIL (MDQ_DETAIL(1,'desc1')));

    -Try to use the negative operator to compare the contents of the trailer of the nested tables, but it gives this error:

    -ORA-00932: inconsistent data types: expected - got DISPATCH. T_MDQ_DETAIL

    Select * from MDQ_NEW

    less

    Select * from MDQ_OLD;

    -Try to select in a ROWTYPE, but it fails

    declare

    myTypeOld MDQ_OLD % ROWTYPE;

    myTypeNew MDQ_New % ROWTYPE;

    myTypeDiff MDQ_New % ROWTYPE;

    Start

    -Select gives: PLS-00497: do not mix between row and several rows (in BULK) list

    Select * bulk collect into mdq_old myTypeOld;

    Select * bulk collect into mdq_new myTypeNew;

    -Need a 'compare the function of membership card' on the types of multiset except to work, but as far as I

    -I'm not able to bulk collect into myTypeOld or myTypeNew, this won't help out me.

    myTypeDiff: = multiset myTypeOld except myTypeNew.

    end;

    -Cleaning:

    drop table MDQ_OLD;

    drop table MDQ_NEW;

    type of projection MDQ_PARENT;

    type of projection T_MDQ_DETAIL;

    type of projection MDQ_DETAIL;

    > queries you provided intercepts not who.

    You asked how to compare the content of nested tables.

    I knew that you didn't ask for what you actually want, that's why I asked you to specify the comparison more in detail.

    > Do you have a query that grabs this difference as well?

    SELECT o.mdq_id, od.*
    OF mdq_old o, TABLE (o.mdq_details) od
    LESS
    SELECT n.mdq_id, nd.*
    OF mdq_new n, TABLE (n.mdq_details) nd;

    > Also, if possible, do you have a sample of a statement to COLLECT LOOSE, please?

    Actually, you raise an interesting point on using % ROWTYPE, in my view, that should be. This make...

    DECLARE
    TYPE rt_mdq_new () IS RENDERING
    mdq_id NUMBER,
    mdq_details t_mdq_detail);
         
    TYPE tt_mdq_new IS TABLE OF THE rt_mdq_new;
      
    t_mdq_new tt_mdq_new;
    BEGIN
    SELECT mdq_id, mdq_details
    LOOSE COLLECTION t_mdq_new
    OF mdq_new min.;
    END;
    /

    DECLARE
    CURSOR c_mdq_new
    IS
    SELECT mn.*
    OF mdq_new min.;
         
    TYPE tt_mdq_new IS TABLE OF c_mdq_new % ROWTYPE;
      
    t_mdq_new tt_mdq_new;
    BEGIN
    OPEN c_mdq_new.
    Get the c_mdq_new COLLECT in BULK IN t_mdq_new;
    CLOSE C_mdq_new;
    END;
    /

  • How to locate the owner of an iPhone that has been reported lost and deleted?

    How to locate the owner of an iPhone that has been reported lost and deleted?

    You return to the police or to the carrier the phone is bound to and let them deal with him. Privacy laws prevent Apple, or the carrier to disclose this information.

  • How to compare the 2 versions of the same document in Pages?

    How to compare the 2 versions of the same document on Pages?

    There is no OS X Visual tool which can open two Pages document and show the differences between them - other than the human eye.

    What information are you interested in identify as different between the two documents? What specific version of Pages?

  • How to find the owner of the Windows Server 2003 product key?

    I found the Windows 2003 product key on my server, I don't know since I'm new to the company the product key is authentic and I have no record. How to find the owner of the product key?

    You find the original product cost and then you are the owner (the company is).

    If not - you have not.  There is no need to register, activate.  When it is activated...

  • HOW TO COMPARE THE REGULAR TEACHER VS VERSIONS?

    HOW TO COMPARE THE REGULAR TEACHER VS VERSIONS?

    Thank you

    An educational version of Photoshop Elements are totally same (feature wise) than the regular commercial versions. So, it is unnecessary to compare.

  • How to compare the new values with the old values in triggers.

    Dear all,

    Please tell me how to compare the new values with the old values in triggers.

    Hi, the employee example is in the document. You'd better read yourself.

    CREATE OR REPLACE TRIGGER Print_salary_changes
      BEFORE DELETE OR INSERT OR UPDATE ON Emp_tab
      FOR EACH ROW
    WHEN (new.Empno > 0)
    DECLARE
        sal_diff number;
    BEGIN
        sal_diff  := :new.sal  - :old.sal;
        dbms_output.put('Old salary: ' || :old.sal);
        dbms_output.put('  New salary: ' || :new.sal);
        dbms_output.put_line('  Difference ' || sal_diff);
    END;
    /
    
  • How to calculate the sum of two digital form fields based on the selection of the checkbox.

    I have a form in Acrobat Pro who needs a custom calculation. How to calculate the sum of two digital form fields based on a selection of the checkbox. I have three number fields. Field-A and B are simple one or two digits. Field-C is the sum, or the total field. I want to field-C have a control box which, when turned on and off, just gives a. gives the sum of A + B

    _ Field - 2

    _ Field - A 4

    [check] _ _ field - 6 C

    [disabled] _ _ field - 2 C

    Thank you

    The custom field C calculation script could be:

    (function () {
    
        // Get the values of the text fields, as numbers
        var v1 = +getField("A").value;
        var v2 = +getField("B").value;
    
        // Set this field's value based on the state of the check box named "CB"
        if (getField("CB").value !== "Off") {
            event.value = v1 + v2;
        } else {
            event.value = v1;
        }
    
    })();
    

    Replace 'A', 'B', and 'CB' with the real names of the fields.

  • Does anyone know how to change the composition of Adobe Creative cloud AE single app to the student member that includes the creation?

    Does anyone know how to change the composition of Adobe Creative cloud AE single app to the student member that includes the creation?

    Hi Danielle,

    Thanks, I tried to do but unable to communicate with anyone.

    Here you go: Contact customer service

    Thank you

    Kevin

  • compare the fields of two queries

    I need to compare the fields of two queries.

    I went through many articles to asktom help operator less. but I'm not convinced by this method.

    Comaprisons are for about 10 fields.

    So I'm planing to do using sliders and nested loops. performance can be a problem.

    Please give your suggestions or solutions.

    OK, using the data you provided, I get this:

    with map_test_fac as (select 100 idid, 789 ifid, 300 edid, 741 efid from dual union all
                          select 100 idid, 123 ifid, 300 edid, 963 efid from dual union all
                          select 100 idid, 456 ifid, 300 edid, 258 efid from dual),
             test_fac as (select 741 facid, 'ETY' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all
                          select 789 facid, 'WE' type, 'EUR' ccy, 'Int' src, 100 did from dual union all
                          select 123 facid, 'VPR' type, 'EUR' ccy, 'Int' src, 100 did from dual union all
                          select 456 facid, 'ETY' type, 'USD' ccy, 'Int' src, 100 did from dual union all
                          select 963 facid, 'WE' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all
                          select 258 facid, 'VPR' type, 'EUR' ccy, 'Ext' src, 300 did from dual)
    -- end of mimicking your data: USE SQL below:
    select tfi.facid int_facid,
           tfi.type int_type,
           tfi.ccy int_ccy,
           tfi.src int_src,
           tfi.did int_did,
           tfe.facid ext_facid,
           tfe.type ext_type,
           tfe.ccy ext_ccy,
           tfe.src ext_src,
           tfe.did ext_did
    from   test_fac tfi,
           test_fac tfe,
           map_test_fac mtf
    where  mtf.ifid = tfi.facid
    and    mtf.efid = tfe.facid
    and    mtf.idid = tfi.did
    and    mtf.edid = tfe.did
    and    (tfi.type != tfe.type
            or tfi.ccy != tfe.ccy)
    
     INT_FACID INT INT INT    INT_DID  EXT_FACID EXT EXT EXT    EXT_DID
    ---------- --- --- --- ---------- ---------- --- --- --- ----------
           789 WE  EUR Int        100        741 ETY EUR Ext        300
           123 VPR EUR Int        100        963 WE  EUR Ext        300
           456 ETY USD Int        100        258 VPR EUR Ext        300
    

    However, I think that your mapping data is incorrect, so with keys of information:

    with map_test_fac as (select 100 idid, 789 ifid, 300 edid, 963 efid from dual union all
                          select 100 idid, 123 ifid, 300 edid, 258 efid from dual union all
                          select 100 idid, 456 ifid, 300 edid, 741 efid from dual),
             test_fac as (select 741 facid, 'ETY' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all
                          select 789 facid, 'WE' type, 'EUR' ccy, 'Int' src, 100 did from dual union all
                          select 123 facid, 'VPR' type, 'EUR' ccy, 'Int' src, 100 did from dual union all
                          select 456 facid, 'ETY' type, 'USD' ccy, 'Int' src, 100 did from dual union all
                          select 963 facid, 'WE' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all
                          select 258 facid, 'VPR' type, 'EUR' ccy, 'Ext' src, 300 did from dual)
    -- end of mimicking your data: USE SQL below:
    select tfi.facid int_facid,
           tfi.type int_type,
           tfi.ccy int_ccy,
           tfi.src int_src,
           tfi.did int_did,
           tfe.facid ext_facid,
           tfe.type ext_type,
           tfe.ccy ext_ccy,
           tfe.src ext_src,
           tfe.did ext_did
    from   test_fac tfi,
           test_fac tfe,
           map_test_fac mtf
    where  mtf.ifid = tfi.facid
    and    mtf.efid = tfe.facid
    and    mtf.idid = tfi.did
    and    mtf.edid = tfe.did
    and    (tfi.type != tfe.type
            or tfi.ccy != tfe.ccy)
    
     INT_FACID INT INT INT    INT_DID  EXT_FACID EXT EXT EXT    EXT_DID
    ---------- --- --- --- ---------- ---------- --- --- --- ----------
           456 ETY USD Int        100        741 ETY EUR Ext        300
    

    That's more like what you're looking for?

Maybe you are looking for

  • Where is the CCI option

    I want to send a message to 3 or 4 people but can't find the bcc option.

  • Looking for a case that is compatible with a HD from Hitachi for a 2006-2008 Blackbook.

    Hi all I have an old hard drive Hitachi to a Macbook black circa 2006-2008 (it was my mom of not sure of the exact year). I've been carting this thing around for years and is trying to find a hard drive enclosure that is compatible. The drive is a Hi

  • How to change photo display options?

    10.11 OS on iMac in Photos. I would like to see pictures on the top and not the bottom of the window / page. Where are the basic functions of a gone Mac usage? I can't find any option to change my preference viewing? Pls help.

  • All-in-one printer will not print documents.

    I tried to print documents from my printer on a computer with XP operating system and transplanted paper and went out in white. I put the printer on my other computer with a 8.1 operating system and get the same results. I ran the printing and scanni

  • How open Bay HARD drive in a TouchSmart from HP Envy 15 laptop j000 t?

    I removed the battery and there is a screw for the hard drive bay that I also removed. There are also 5 other screws around the back that I removed, but I can't remove the back. Do you have any suggestions on what I should do? Thank you