Skip to content

Instantly share code, notes, and snippets.

@robdecker
Last active November 2, 2019 01:47
Show Gist options
  • Save robdecker/9084883 to your computer and use it in GitHub Desktop.
Save robdecker/9084883 to your computer and use it in GitHub Desktop.
[Clear Drupal cache via SQL] #d7

Steps to follow:

  • Replace {db_name} by the real project's database name.
  • Execute the sentence.
  • Copy the generated string (TRUNCATE list, one for each table).
  • Execute the string copied in the previous step (TRUNCATE list).
SELECT
CONCAT('TRUNCATE TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') AS table_name
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = '{db_name}'
AND TABLE_NAME LIKE 'cache_%'
AND TABLE_TYPE = 'BASE TABLE'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment