答案 0 :(得分:2)
试试这个:
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'your_schema' AND
TABLE_NAME = 'table2' AND
COLUMN_NAME NOT IN (
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'your_schema' AND
TABLE_NAME = 'table1');
上述查询返回table2
中不存在的table1
列名。