Skip to content

Instantly share code, notes, and snippets.

@thiagoeliasr
Created August 21, 2019 18:50
Show Gist options
  • Save thiagoeliasr/d283e1b90c902e7981b3faf363eb9bb4 to your computer and use it in GitHub Desktop.
Save thiagoeliasr/d283e1b90c902e7981b3faf363eb9bb4 to your computer and use it in GitHub Desktop.
# Code below will show the truncate code for all tables in desired schema
SELECT
Concat('TRUNCATE TABLE ', TABLE_NAME, ';')
FROM
INFORMATION_SCHEMA.TABLES
WHERE
table_schema = 'your-table';
# disabling foreign checks for a while
SET FOREIGN_KEY_CHECKS=0;
# put the result of select above here
SET FOREIGN_KEY_CHECKS=1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment