Last active
August 15, 2016 05:19
-
-
Save KarelWintersky/90f1a2a0d3340cf4ba3b5e106afac589 to your computer and use it in GitHub Desktop.
Fiddling with MySQL: information_scheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$check_tables = array( | |
'table_1', 'table_2', 'table_3' | |
); | |
$check_tables_strs = array_map(function($n){ | |
return "SELECT '{$n}' as table_name"; | |
}, $check_tables); | |
$unions = implode($check_tables_strs, " UNION ALL \n"); | |
$information_scheme_query = <<<IBQ | |
SELECT | |
tn.table_name, t.table_rows, t.data_length, | |
DATE_FORMAT(t.update_time, '{$date_format}') AS update_time_visible, t.update_time | |
FROM ( | |
{$unions} | |
) tn LEFT JOIN | |
information_schema.tables t | |
ON tn.table_name = t.table_name; | |
IBQ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment