Skip to content

Instantly share code, notes, and snippets.

@utdrmac
Created May 4, 2016 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utdrmac/9297fe2cf3dafb4f662491a46caeda6d to your computer and use it in GitHub Desktop.
Save utdrmac/9297fe2cf3dafb4f662491a46caeda6d to your computer and use it in GitHub Desktop.
SELECT t.table_schema, t.engine, t.table_name, c.column_name, c.column_type
FROM information_schema.tables AS t
INNER JOIN information_schema.columns AS c ON c.table_schema = t.table_schema
AND c.table_name = t.table_name
LEFT OUTER JOIN information_schema.innodb_sys_tables AS ist
ON ist.name = concat(t.table_schema,'/',t.table_name)
LEFT OUTER JOIN information_schema.innodb_sys_columns AS isc
ON isc.table_id = ist.table_id AND isc.name = c.column_name
WHERE c.column_type IN ('time','timestamp','datetime')
AND t.table_schema NOT IN ('mysql','information_schema','performance_schema')
AND t.table_type = 'base table'
AND (t.engine = 'innodb' and isc.mtype = 6)
ORDER BY t.table_schema, t.table_name, c.column_name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment