Skip to content

Instantly share code, notes, and snippets.

@davewalk
Created September 18, 2014 15:40
Show Gist options
  • Save davewalk/5211e7db094cee5082ca to your computer and use it in GitHub Desktop.
Save davewalk/5211e7db094cee5082ca to your computer and use it in GitHub Desktop.
mySQL metadata queries
# Get the charset of a table
SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,
information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
WHERE CCSA.collation_name = T.table_collation
AND T.table_schema = "schemaname"
AND T.table_name = "tablename";
# Get a bunch of details about a table including its collation
SHOW TABLE STATUS IN dbname like 'tablename'
# Get the list of processes the database is currently running
SHOW FULL PROCESSLIST\G
# Get a list of indexes for a database
select index_name from information_schema.statistics;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment