[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);

ご利用は計画的に


Posted

in

by

Tags:

Comments

コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト /  変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト /  変更 )

%s と連携中

%d人のブロガーが「いいね」をつけました。