Compare column for different tables on different databases.

Links: http://www.dbatools.net/mytools/compare_column_all_type.html

    I will introduce you how to compare structure for different tables in different databases (ALL type) with the compare any column utility (Overview / Download). I create the following tables in three different databases for this demo.

-- dbchina
CREATE TABLE SALES_CN (COL1 NUMBER(10), COL2 NUMBER(12,2));
-- dbus
CREATE TABLE SALES_US (COL1 NUMBER(10), COL2 NUMBER(15,2));
-- dbother
CREATE TABLE SALES_OTHER (
        COL1 NUMBER(10), COL2 NUMBER(15,2), COL3 DATE);

    Then we need to write a configuration file, to tell this utility which tables are compared together, the minus char means the next line continues the previous.

ALL: -
  sales_cn!sh@dbchina | -
  sales_us!sh@dbus | -
  sales_other!sh@dbother

    Now we can run this utility with the following command.

companycol.pl -f all_demo.cfg

    Then check the screen output or check the log file generated (with "-l" option).

Comparing structure of tables on different hosts ...
Tables
       sales_cn         sales_us        sales_other
     [MISMATCH] COL2 NUMBER(12,2) :
                       sales_cn!dbchina
     [MISMATCH] COL2 NUMBER(15,2) :
                       sales_us!dbus    sales_other!dbother
     [MISSING ] COL3 :
               sales_cn!dbchina         sales_us!dbus

    It seems not so easy to create the configuration file, right?

Post a comment

« Previous | Main | Next »

Powered by
Movable Type 3.36