Skip to content

Instantly share code, notes, and snippets.

@secretorange
Last active April 26, 2018 07:47
Show Gist options
  • Save secretorange/6b2ff13fc55815be7c9d2593ffc6bd2f to your computer and use it in GitHub Desktop.
Save secretorange/6b2ff13fc55815be7c9d2593ffc6bd2f to your computer and use it in GitHub Desktop.

My SQL Snippets

Process List

SHOW PROCESSLIST

DROP all tables

SELECT concat('DROP TABLE IF EXISTS `', table_schema, '`.`', table_name, '`;')
FROM information_schema.tables
WHERE table_schema = 'DATABASE_NAME_HERE';

Then use:

SET FOREIGN_KEY_CHECKS = 0;

-- COPY AND PASTE LIST FROM ABOVE SQL

SET FOREIGN_KEY_CHECKS = 1;

EXPLAIN how indexes are used in a SELECT

EXPLAIN SELECT * FROM my_table;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment