Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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
You can’t perform that action at this time.