Skip to content

Instantly share code, notes, and snippets.

@yordanoweb
Last active February 23, 2025 16:26
Show Gist options
  • Save yordanoweb/edc1fb165889255fc1c6b0537c5c822c to your computer and use it in GitHub Desktop.
Save yordanoweb/edc1fb165889255fc1c6b0537c5c822c to your computer and use it in GitHub Desktop.
MySQL useful queries

Useful SQL queries

List databases by creation date

SELECT table_schema AS Database_Name, MIN(create_time) AS Creation_Time FROM information_schema.tables WHERE table_schema like 'some_db_name%' Group by table_schema;

List databases with size

SELECT table_schema "DB Name",ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"  FROM information_schema.tables  GROUP BY table_schema;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment