List:General Discussion« Previous MessageNext Message »
From:Gordon Bruce Date:August 26 2005 2:56pm
Subject:RE: Compare two tables
View as plain text  
If you have the 5.0.x version of MySQL then INFROMATION SCHEMA can give
you what you want. i.e. 

SELECT a.*, b.* 
FROM   INFORMATION_SCHEMA.COLUMNS AS a 
       INNER JOIN _SCHEMA.COLUMNS AS b 
       ON (a.column_name = b.column_name) 
WHERE  a.TABLE_NAME = 'foo_1' 
       AND b.TABLE_NAME = 'foo_2'

If you look up INFORMATION SCHEMA in the documentation you will find the
table definitions to chose the columns you need for your comparison.

21. The INFORMATION_SCHEMA Information Database 
21.1. INFORMATION_SCHEMA Tables

-----Original Message-----
From: Alfredo Cole [mailto:alfredo@stripped] 
Sent: Friday, August 26, 2005 9:08 AM
To: mysql@stripped
Subject: Compare two tables

Hi:

I need to compare the structure of two tables (fields, field types,
field 
lengths, indices, etc.) to determine if they have the same schema, even
if 
the fields may be in a different order. Is there a command in mysql that
will 
do this? This will be used to determine if the tables are basically the
same, 
or if they need to be upgraded based on the table structures of a
central 
office.

Thank you.

-- 
Alfredo J. Cole
Grupo ACyC

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/mysql?unsub=1



Thread
Compare two tablesAlfredo Cole26 Aug
  • Re: Compare two tablesSGreen26 Aug
  • Re: Compare two tablesMartijn Tonies26 Aug
    • Re: Compare two tablesAlfredo Cole26 Aug
      • Re: Compare two tablesMark Addison26 Aug
  • Re: Compare two tablesMartijn Tonies26 Aug
  • Re: Compare two tablesPeter Brawley26 Aug
RE: Compare two tablesGordon Bruce26 Aug
  • Re: Compare two tablesAlfredo Cole26 Aug