Sample Header Ad - 728x90

Query to compare the structure of two tables in MySQL

31 votes
9 answers
74201 views
To automate the backup process of one of my MySQL databases, I would like to compare the structure of two tables (current version vs old version). Can you think of a query that can compare two tables? Here are some example tables that you can compare. CREATE TABLE product_today ( pname VARCHAR(150), price int, PRIMARY KEY (pname) ); CREATE TABLE product_yesterday ( pname VARCHAR(150), price int, PRIMARY KEY (pname) ); CREATE TABLE product_2days_back ( pname VARCHAR(15), price int, PRIMARY KEY (pname) ); The first two tables have identical structures. The last one is different. I just need to know whether two tables have different structures or not. I'm not interested in the how they differ.
Asked by sjdh (767 rep)
Sep 3, 2014, 12:42 AM
Last activity: Jul 16, 2024, 10:07 AM