Skip to content

Instantly share code, notes, and snippets.

@shellj
Created September 5, 2022 09:27
Show Gist options
  • Save shellj/f353eea5453d9b1493c70820e3875c5c to your computer and use it in GitHub Desktop.
Save shellj/f353eea5453d9b1493c70820e3875c5c to your computer and use it in GitHub Desktop.
get the difference between two tables in MySQL
SELECT table_name,
column_name,
ordinal_position,
data_type,
column_type,
COLUMN_DEFAULT,
COLUMN_COMMENT
FROM (SELECT table_name,
column_name,
ordinal_position,
data_type,
column_type,
COLUMN_DEFAULT,
COLUMN_COMMENT
FROM information_schema.columns
WHERE table_schema in ('message', 'data_archive')
AND table_name IN ('message', '2022_message')
GROUP BY column_name, ordinal_position,
data_type, column_type, COLUMN_DEFAULT, COLUMN_COMMENT
HAVING COUNT(1) = 1) A;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment