Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Created May 24, 2013 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wokamoto/5642733 to your computer and use it in GitHub Desktop.
Save wokamoto/5642733 to your computer and use it in GitHub Desktop.
[WordPress] 使ってない meta 情報をテーブルから消去する SQL
delete from wp_postmeta
where not exists (select 'x' from wp_posts where wp_posts.ID = wp_postmeta.post_id);
delete from wp_comments
where not exists (select 'x' from wp_posts where wp_posts.ID = wp_comments.comment_post_id);
delete from wp_commentmeta
where not exists (select 'x' from wp_comments where wp_comments.comment_id = wp_commentmeta.comment_id);
delete from wp_usermeta
where not exists (select 'x' from wp_users where wp_users.ID = wp_usermeta.user_id);
delete from wp_term_taxonomy
where not exists (select 'x' from wp_terms where wp_terms.term_id = wp_term_taxonomy.term_id);
delete from wp_term_relationships
where not exists (select 'x' from wp_term_taxonomy where wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment