Skip to content

Instantly share code, notes, and snippets.

@duderamos
Last active July 26, 2021 05:16
Show Gist options
  • Save duderamos/c004e519e96a5fe8a9f5ee82f1c8bf91 to your computer and use it in GitHub Desktop.
Save duderamos/c004e519e96a5fe8a9f5ee82f1c8bf91 to your computer and use it in GitHub Desktop.

MySQL commands

  • Show table collation from a database:
show table status from <database>;
  • Show collation from an entire database;
select default_character_set_name from information_schema.schemata s where schema_name = '<database>';
  • Show column collcation:
show full columns from <table>;
  • Alter charset and collation of a database:
alter database <database> character set utf8 collate utf8_unicode_ci;
  • Alter charset and collation of a table:
alter table <table> convert to character set utf8 collate utf8_unicode_ci;
  • Database size on disk:
SELECT table_name AS `Table`, round((data_length / 1024 / 1024), 2) `Size of Data (MB)`, round((index_length / 1024 / 1024), 2) `Size of Index (MB)` FROM information_schema.TABLES WHERE table_schema = "<database>" order by `Size of Data (MB)` desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment