Results 1 to 4 of 4

Threaded View

  1. #2
    Join Date
    Jun 2008
    Location
    Japan
    Posts
    208
    Plugin Contributions
    7

    Default Re: Comparing tables structure fromdifferent databases (versions)

    Quote Originally Posted by pilou2 View Post
    ...
    I found a way to compare two tables using MySQL derivated tables. It might be usefull to others, so here it is:
    This query compares tables 'customers' from two different databases (here 'vanilla' and 'prod').

    Code:
    SELECT column_name,ordinal_position,data_type,column_type FROM 
    ( SELECT column_name,ordinal_position, data_type,column_type,COUNT(1) rowcount FROM information_schema.columns WHERE 
    ( (table_schema='vanilla' AND table_name='customers') OR (table_schema='prod' AND table_name='customers') ) 
    GROUP BY column_name,ordinal_position, data_type,column_type HAVING COUNT(1)=1 ) A;
    ...
    Well it seems I was tired when I did this post... I use derived table and not 'derivated'... And the SQL query is not optimized at all, there are some useless stuff left over...
    The following query returns differences between tables 'products' in databases 'vanilla' and 'prod' based on GROUP BY parameters:

    Code:
    SELECT db as 'Database',column_name,ordinal_position,data_type,column_type FROM 
    ( SELECT table_schema as db,column_name,ordinal_position,data_type,column_type FROM information_schema.columns WHERE 
    ( (table_schema='vanilla' AND table_name='products') OR (table_schema='prod' AND table_name='products') ) 
    GROUP BY column_name,data_type,column_type HAVING COUNT(1)=1 ) as A 
    ORDER BY ordinal_position ASC;
    Last edited by pilou2; 17 Oct 2023 at 07:36 PM.

 

 

Similar Threads

  1. Can Templates from Prior Versions Be Added to Later Versions?
    By PSurf in forum Templates, Stylesheets, Page Layout
    Replies: 18
    Last Post: 6 Dec 2011, 02:38 AM
  2. Question about file comparing
    By bluetooth in forum Upgrading from 1.3.x to 1.3.9
    Replies: 1
    Last Post: 15 Jun 2010, 04:48 PM
  3. Comparing Zen Vesions
    By Renz in forum Upgrading from 1.3.x to 1.3.9
    Replies: 10
    Last Post: 1 Jun 2010, 09:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR