{"id":10386,"date":"2026-09-11T07:20:00","date_gmt":"2026-09-11T05:20:00","guid":{"rendered":"https:\/\/www.lukaswojcik.com\/blog\/?p=10386"},"modified":"2026-10-24T04:33:04","modified_gmt":"2026-10-24T02:33:04","slug":"wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves","status":"publish","type":"post","link":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/","title":{"rendered":"WP-CLI Delete Commands: Which Tables Each One Touches and What It Leaves Behind"},"content":{"rendered":"<p>Deleting WordPress data means more than removing a table row. Application functions account for relationships, counts, caches and extensions. Direct SQL bypasses these workflows. The important questions are the selected objects, side effects and a backup that can actually be restored.<\/p>\n<p><code>wp post delete<\/code> and <code>wp comment delete<\/code> have no built-in <code>--dry-run<\/code>. Other WP-CLI commands do provide one. A preliminary list shows the selected objects, but does not simulate hooks or file changes and does not count every affected database row.<\/p>\n<figure class=\"lw-diagram\"><img decoding=\"async\" src=\"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/diagrams\/dia-10386-wpdelete-20261024.png\" width=\"1120\" height=\"580\" loading=\"lazy\" alt=\"WP-CLI: SELECTION IS NOT A FULL DRY RUN\"><figcaption>A database dump does not contain uploaded media files.<\/figcaption><\/figure>\n<h2>Save and review the selection before deletion<\/h2>\n<p>This Bash example exports the database and saves a fixed list of all revisions with status <code>inherit<\/code>. The installation path, site URL and private backup directory are placeholders requiring adaptation. The backup directory must be outside the webroot and any public web-server alias.<\/p>\n<figure style=\"--cbb-digits:2\" class=\"cbb cbb--wrap cbb--numbers wp-block-code-beautifier-block-code\" data-lang=\"bash\"><figcaption class=\"cbb-head\"><span class=\"cbb-lang\">Shell<\/span><span class=\"cbb-actions\"><button type=\"button\" class=\"cbb-button cbb-button--wrap\" data-cbb-action=\"wrap\" aria-pressed=\"true\" title=\"Wrap long lines\"><svg aria-hidden=\"true\" focusable=\"false\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><path d=\"M2 4h12M2 8h9.5a2.5 2.5 0 0 1 0 5H8m0 0 1.5-1.5M8 13l1.5 1.5M2 12h3\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg><span class=\"cbb-sr\">Wrap long lines<\/span><\/button><button type=\"button\" class=\"cbb-button cbb-button--copy\" data-cbb-action=\"copy\" data-cbb-done=\"Copied\" data-cbb-failed=\"Press Ctrl+C to copy\"><svg aria-hidden=\"true\" focusable=\"false\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><rect x=\"5.5\" y=\"5.5\" width=\"8\" height=\"8.5\" rx=\"1.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M10.5 3.5V3A1.5 1.5 0 0 0 9 1.5H4A1.5 1.5 0 0 0 2.5 3v6.5A1.5 1.5 0 0 0 4 11h.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><\/svg><span class=\"cbb-button-label\" aria-live=\"polite\">Copy<\/span><\/button><\/span><\/figcaption><pre class=\"cbb-pre\" tabindex=\"0\"><code class=\"cbb-code language-bash\" style=\"counter-reset:cbb-line 0;\"><span class=\"cbb-line\"><span class=\"cbb-comment\">#!\/usr\/bin\/env bash<\/span>\n<\/span><span class=\"cbb-line\"><span class=\"cbb-keyword\">set<\/span> <span class=\"cbb-attr\">-euo<\/span> pipefail\n<\/span><span class=\"cbb-line\">umask <span class=\"cbb-number\">077<\/span>\n<\/span><span class=\"cbb-line\">wp_path=\/srv\/www\/example-wordpress\n<\/span><span class=\"cbb-line\">site_url=https:\/\/example.invalid\n<\/span><span class=\"cbb-line\">backup_dir=\/srv\/private\/wp-backups\n<\/span><span class=\"cbb-line\"><span class=\"cbb-function\">mkdir<\/span> <span class=\"cbb-attr\">-p<\/span> -- <span class=\"cbb-string\">\"<\/span><span class=\"cbb-variable\">$backup_dir<\/span><span class=\"cbb-string\">\"<\/span>\n<\/span><span class=\"cbb-line\">run_dir=<span class=\"cbb-variable\">$(<\/span>mktemp <span class=\"cbb-attr\">-d<\/span> <span class=\"cbb-string\">\"<\/span><span class=\"cbb-variable\">$backup_dir<\/span><span class=\"cbb-string\">\/revisions.XXXXXXXX\"<\/span>)\n<\/span><span class=\"cbb-line\"><span class=\"cbb-function\">wp<\/span> <span class=\"cbb-attr\">--path<\/span>=<span class=\"cbb-string\">\"<\/span><span class=\"cbb-variable\">$wp_path<\/span><span class=\"cbb-string\">\"<\/span> <span class=\"cbb-attr\">--url<\/span>=<span class=\"cbb-string\">\"<\/span><span class=\"cbb-variable\">$site_url<\/span><span class=\"cbb-string\">\"<\/span> db <span class=\"cbb-keyword\">export<\/span> <span class=\"cbb-string\">\"<\/span><span class=\"cbb-variable\">$run_dir<\/span><span class=\"cbb-string\">\/database.sql\"<\/span>\n<\/span><span class=\"cbb-line\"><span class=\"cbb-function\">wp<\/span> <span class=\"cbb-attr\">--path<\/span>=<span class=\"cbb-string\">\"<\/span><span class=\"cbb-variable\">$wp_path<\/span><span class=\"cbb-string\">\"<\/span> <span class=\"cbb-attr\">--url<\/span>=<span class=\"cbb-string\">\"<\/span><span class=\"cbb-variable\">$site_url<\/span><span class=\"cbb-string\">\"<\/span> post list \\\n<\/span><span class=\"cbb-line\">  <span class=\"cbb-attr\">--post_type<\/span>=revision <span class=\"cbb-attr\">--post_status<\/span>=inherit <span class=\"cbb-attr\">--posts_per_page<\/span>=<span class=\"cbb-number\">-1<\/span> \\\n<\/span><span class=\"cbb-line\">  <span class=\"cbb-attr\">--orderby<\/span>=ID <span class=\"cbb-attr\">--order<\/span>=ASC <span class=\"cbb-attr\">--format<\/span>=ids <span class=\"cbb-operator\">&gt;<\/span> <span class=\"cbb-string\">\"<\/span><span class=\"cbb-variable\">$run_dir<\/span><span class=\"cbb-string\">\/revision-ids.txt\"<\/span>\n<\/span><span class=\"cbb-line\"><span class=\"cbb-function\">wc<\/span> <span class=\"cbb-attr\">-w<\/span> &lt; <span class=\"cbb-string\">\"<\/span><span class=\"cbb-variable\">$run_dir<\/span><span class=\"cbb-string\">\/revision-ids.txt\"<\/span>\n<\/span><span class=\"cbb-line\"><span class=\"cbb-function\">printf<\/span> <span class=\"cbb-string\">'Review directory: %s\\n'<\/span> <span class=\"cbb-string\">\"<\/span><span class=\"cbb-variable\">$run_dir<\/span><span class=\"cbb-string\">\"<\/span><\/span><\/code><\/pre><\/figure>\n<p>The next step requires reviewing the IDs and associated posts, a successful export and a tested restore. An SQL dump contains no media files: media deletion also requires an uploads backup and, where relevant, external-storage backups. Consistency on a live system depends on table engines and ongoing writes. Successful export alone does not prove complete recoverability.<\/p>\n<p>The following <strong>separate deletion step<\/strong> uses only the reviewed file. <code>run_dir<\/code> must identify the directory created earlier. Revisions are permanently removed; the selection can include autosaves.<\/p>\n<figure style=\"--cbb-digits:1\" class=\"cbb cbb--wrap cbb--numbers wp-block-code-beautifier-block-code\" data-lang=\"bash\"><figcaption class=\"cbb-head\"><span class=\"cbb-lang\">Shell<\/span><span class=\"cbb-actions\"><button type=\"button\" class=\"cbb-button cbb-button--wrap\" data-cbb-action=\"wrap\" aria-pressed=\"true\" title=\"Wrap long lines\"><svg aria-hidden=\"true\" focusable=\"false\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><path d=\"M2 4h12M2 8h9.5a2.5 2.5 0 0 1 0 5H8m0 0 1.5-1.5M8 13l1.5 1.5M2 12h3\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg><span class=\"cbb-sr\">Wrap long lines<\/span><\/button><button type=\"button\" class=\"cbb-button cbb-button--copy\" data-cbb-action=\"copy\" data-cbb-done=\"Copied\" data-cbb-failed=\"Press Ctrl+C to copy\"><svg aria-hidden=\"true\" focusable=\"false\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><rect x=\"5.5\" y=\"5.5\" width=\"8\" height=\"8.5\" rx=\"1.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M10.5 3.5V3A1.5 1.5 0 0 0 9 1.5H4A1.5 1.5 0 0 0 2.5 3v6.5A1.5 1.5 0 0 0 4 11h.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><\/svg><span class=\"cbb-button-label\" aria-live=\"polite\">Copy<\/span><\/button><\/span><\/figcaption><pre class=\"cbb-pre\" tabindex=\"0\"><code class=\"cbb-code language-bash\" style=\"counter-reset:cbb-line 0;\"><span class=\"cbb-line\">wp_path=\/srv\/www\/example-wordpress\n<\/span><span class=\"cbb-line\">site_url=https:\/\/example.invalid\n<\/span><span class=\"cbb-line\">run_dir=\/srv\/private\/wp-backups\/revisions.REVIEWED\n<\/span><span class=\"cbb-line\"><span class=\"cbb-function\">xargs<\/span> <span class=\"cbb-attr\">-r<\/span> <span class=\"cbb-attr\">-n<\/span> <span class=\"cbb-number\">100<\/span> <span class=\"cbb-function\">wp<\/span> <span class=\"cbb-attr\">--path<\/span>=<span class=\"cbb-string\">\"<\/span><span class=\"cbb-variable\">$wp_path<\/span><span class=\"cbb-string\">\"<\/span> <span class=\"cbb-attr\">--url<\/span>=<span class=\"cbb-string\">\"<\/span><span class=\"cbb-variable\">$site_url<\/span><span class=\"cbb-string\">\"<\/span> \\\n<\/span><span class=\"cbb-line\">  post delete <span class=\"cbb-attr\">--force<\/span> &lt; <span class=\"cbb-string\">\"<\/span><span class=\"cbb-variable\">$run_dir<\/span><span class=\"cbb-string\">\/revision-ids.txt\"<\/span><\/span><\/code><\/pre><\/figure>\n<p><code>xargs -n 100<\/code> limits IDs per invocation; GNU xargs <code>-r<\/code> prevents execution with empty input. An oversized single argument list normally fails at process startup. Multiple batches, however, may succeed only partially: this is not a transaction. Exit status, logs and remaining objects require checking. A saved list prevents reselection, but not concurrent system changes; larger cleanups benefit from a controlled maintenance window.<\/p>\n<h2>What application functions handle<\/h2>\n<p>Permanent deletion of an ordinary post removes related post metadata, comments and their metadata, revisions and taxonomy relationships. The terms themselves normally remain. Attachments are not automatically deleted together with the post; parent relationships may change. Hooks allow extensions to perform cleanup, but do not guarantee complete cleanup by every extension. Skipping plugins may also omit their hooks.<\/p>\n<p>A direct SQL DELETE of the post row does not execute these WordPress workflows. Without custom database triggers or relationships, dependent records and potentially stale cache entries remain. Such rows are still queryable. Later reuse of the same ID can create incorrect associations, but is not an inevitable result of every import.<\/p>\n<table><thead><tr><th>Command<\/th><th>Effect and limit<\/th><\/tr><\/thead><tbody>\n<tr><td><code>wp post delete 123 --force<\/code><\/td><td>Permanent application-level deletion; an ordinary post does not automatically take attached media with it.<\/td><\/tr>\n<tr><td><code>wp post delete 456 --force<\/code>, when 456 is an attachment<\/td><td>Deletes the attachment and files\/sizes known to WordPress. External copies, plugin variants and filesystem failures need separate checks; content links may break.<\/td><\/tr>\n<tr><td><code>wp comment delete 789 --force<\/code><\/td><td>Deletes the comment and metadata; core updates the post count for approved comments and adjusts child relationships.<\/td><\/tr>\n<tr><td><code>wp transient delete --expired<\/code><\/td><td>Removes expired database transients; values without expiration remain.<\/td><\/tr>\n<tr><td><code>wp db optimize<\/code><\/td><td>Invokes mysqlcheck for table optimisation; does not clean up WordPress content.<\/td><\/tr><\/tbody><\/table>\n<p>The numbers are illustrative IDs. Spam selection uses <code>wp comment list --status=spam --format=ids<\/code>; <code>wp comment delete --status=spam<\/code> does not replace an ID list. A targeted repair for a demonstrated count discrepancy is, for example, <code>wp comment recount 123<\/code>, using a post ID. Ordinary core deletion does not inherently require a recount.<\/p>\n<h2>Trash and caches have different limits<\/h2>\n<p>Without <code>--force<\/code>, WP-CLI moves eligible posts into enabled trash. Already trashed entries, revisions or disabled trash can still result in permanent deletion. Trashing changes related administrative data as well as status and is not an independent backup.<\/p>\n<p>Transients are disposable cache values and may disappear before their nominal expiry. <code>--all<\/code> also includes database values without expiration. Rebuilding may cause load or reveal plugin failures; \u201cnothing can break\u201d is not a defensible guarantee.<\/p>\n<p>With persistent object caching, individual and bulk deletion differ. <code>wp transient delete KEY<\/code> uses the WordPress API and can remove a key in the active cache. In the reviewed WP-CLI implementation, <code>--all<\/code> and <code>--expired<\/code> instead operate on database records and warn about external caching. A supported backend allows group flushing through <code>wp cache flush-group<\/code>; the correct group and scope must be established. A complete <code>wp cache flush<\/code> affects much more and may reach other sites depending on the backend.<\/p>\n<h2>Evaluate OPTIMIZE TABLE deliberately<\/h2>\n<p>MySQL generally rebuilds ordinary InnoDB tables online for <code>OPTIMIZE TABLE<\/code>. Exclusive locks occur particularly during preparation and commit; some settings or FULLTEXT indexes require a different procedure. MariaDB, engine and version need separate assessment. A continuous write lock is not a universal InnoDB rule.<\/p>\n<p>Deleted space can be reused internally. Returning space to the filesystem depends on factors including tablespace layout and rebuilding, not on whether any writes occurred after deletion. Planning needs to account for runtime, temporary space, I\/O and lock waits. This does not justify an indiscriminate nightly job.<\/p>\n<div class=\"lw-faq\"><h2>Questions and answers<\/h2>\n<h3>How can orphaned metadata be investigated?<\/h3><p>A read-only anti-join provides an initial finding. The <code>wp_<\/code> prefix must match the selected site:<\/p><figure style=\"--cbb-digits:1\" class=\"cbb cbb--wrap wp-block-code-beautifier-block-code\" data-lang=\"bash\"><figcaption class=\"cbb-head\"><span class=\"cbb-lang\">Shell<\/span><span class=\"cbb-actions\"><button type=\"button\" class=\"cbb-button cbb-button--wrap\" data-cbb-action=\"wrap\" aria-pressed=\"true\" title=\"Wrap long lines\"><svg aria-hidden=\"true\" focusable=\"false\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><path d=\"M2 4h12M2 8h9.5a2.5 2.5 0 0 1 0 5H8m0 0 1.5-1.5M8 13l1.5 1.5M2 12h3\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg><span class=\"cbb-sr\">Wrap long lines<\/span><\/button><button type=\"button\" class=\"cbb-button cbb-button--copy\" data-cbb-action=\"copy\" data-cbb-done=\"Copied\" data-cbb-failed=\"Press Ctrl+C to copy\"><svg aria-hidden=\"true\" focusable=\"false\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><rect x=\"5.5\" y=\"5.5\" width=\"8\" height=\"8.5\" rx=\"1.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><path d=\"M10.5 3.5V3A1.5 1.5 0 0 0 9 1.5H4A1.5 1.5 0 0 0 2.5 3v6.5A1.5 1.5 0 0 0 4 11h.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"\/><\/svg><span class=\"cbb-button-label\" aria-live=\"polite\">Copy<\/span><\/button><\/span><\/figcaption><pre class=\"cbb-pre\" tabindex=\"0\"><code class=\"cbb-code language-bash\" style=\"counter-reset:cbb-line 0;\"><span class=\"cbb-line\"><span class=\"cbb-function\">wp<\/span> db query <span class=\"cbb-string\">'SELECT COUNT(*) FROM wp_postmeta pm LEFT JOIN wp_posts p ON p.ID = pm.post_id WHERE p.ID IS NULL'<\/span><\/span><\/code><\/pre><\/figure><p>Cleanup requires samples, backup, cache-impact assessment and checking possible plugin usage. The pattern must not be applied blindly to taxonomy relationships: objects may also be links, users or plugin objects. An execution plan helps with large tables; no particular access strategy is guaranteed.<\/p>\n<h3>Does WP_POST_REVISIONS immediately cap existing revisions?<\/h3><p>No. A numeric limit takes effect in the regular revision workflow when further revisions are created, subject to filters and autosave exceptions. <code>false<\/code> disables regular revisions without automatically removing existing records. Autosaves need separate consideration.<\/p>\n<h3>What changes with multisite?<\/h3><p>Post commands operate on the selected site; <code>--url<\/code> makes the target explicit. Configuration and aliases may supply defaults. Not all tables are separate per site: user and network tables are shared structures. Network transients need the appropriate <code>--network<\/code> context. Without table filters, <code>wp db export<\/code> covers the configured database, not just the site selected by <code>--url<\/code>.<\/p><\/div><div class=\"lw-quellen\"><h2>Sources<\/h2><ul><li><a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/post\/delete\/\" target=\"_blank\" rel=\"noopener noreferrer\">WP-CLI: wp post delete<\/a><\/li><li><a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/comment\/delete\/\" target=\"_blank\" rel=\"noopener noreferrer\">WP-CLI: wp comment delete<\/a><\/li><li><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_delete_post\/\" target=\"_blank\" rel=\"noopener noreferrer\">WordPress: wp_delete_post<\/a><\/li><li><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_delete_comment\/\" target=\"_blank\" rel=\"noopener noreferrer\">WordPress: wp_delete_comment<\/a><\/li><li><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_delete_attachment\/\" target=\"_blank\" rel=\"noopener noreferrer\">WordPress: wp_delete_attachment<\/a><\/li><li><a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/comment\/recount\/\" target=\"_blank\" rel=\"noopener noreferrer\">WP-CLI: wp comment recount<\/a><\/li><li><a href=\"https:\/\/raw.githubusercontent.com\/wp-cli\/cache-command\/main\/src\/Transient_Command.php\" target=\"_blank\" rel=\"noopener noreferrer\">WP-CLI: Transient command source<\/a><\/li><li><a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/cache\/flush-group\/\" target=\"_blank\" rel=\"noopener noreferrer\">WP-CLI: Cache group flushing<\/a><\/li><li><a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/db\/export\/\" target=\"_blank\" rel=\"noopener noreferrer\">WP-CLI: Database export<\/a><\/li><li><a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/db\/optimize\/\" target=\"_blank\" rel=\"noopener noreferrer\">WP-CLI: Database optimisation<\/a><\/li><li><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.4\/en\/optimize-table.html\" target=\"_blank\" rel=\"noopener noreferrer\">MySQL 8.4: OPTIMIZE TABLE<\/a><\/li><li><a href=\"https:\/\/mariadb.com\/docs\/server\/ha-and-performance\/optimization-and-tuning\/optimizing-tables\/optimize-table\" target=\"_blank\" rel=\"noopener noreferrer\">MariaDB: OPTIMIZE TABLE<\/a><\/li><li><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_save_post_revision\/\" target=\"_blank\" rel=\"noopener noreferrer\">WordPress: Revision creation and retention<\/a><\/li><li><a href=\"https:\/\/raw.githubusercontent.com\/wp-cli\/entity-command\/main\/src\/Post_Command.php\" target=\"_blank\" rel=\"noopener noreferrer\">WP-CLI: Post deletion implementation<\/a><\/li><li><a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/post\/list\/\" target=\"_blank\" rel=\"noopener noreferrer\">WP-CLI: Post selection<\/a><\/li><li><a href=\"https:\/\/developer.wordpress.org\/apis\/transients\/\" target=\"_blank\" rel=\"noopener noreferrer\">WordPress: Transients API<\/a><\/li><li><a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/\" target=\"_blank\" rel=\"noopener noreferrer\">WP-CLI: Command reference<\/a><\/li><\/ul><\/div>","protected":false},"excerpt":{"rendered":"<p>WP-CLI deletion affects relationships, metadata, files and caches differently. A reviewed ID list, a restorable backup and checks of command scope help avoid incomplete or unintended cleanup.<\/p>\n","protected":false},"author":1,"featured_media":15164,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[91104,91096],"class_list":["post-10386","post","type-post","status-publish","format-standard","hentry","category-wordpress-plugins-tricks","tag-mysql","tag-wordpress"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>WP-CLI Delete Commands: Which Tables Each One Touches and What It Leaves Behind | Lukas Wojcik<\/title>\n<meta name=\"description\" content=\"Revisions, transients, spam and orphaned meta: what each WP-CLI delete command actually removes, and the two-step pattern that replaces the missing dry run.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WP-CLI Delete Commands: Which Tables Each One Touches and What It Leaves Behind | Lukas Wojcik\" \/>\n<meta property=\"og:description\" content=\"Revisions, transients, spam and orphaned meta: what each WP-CLI delete command actually removes, and the two-step pattern that replaces the missing dry run.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/\" \/>\n<meta property=\"og:site_name\" content=\"Lukas Wojcik - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-11T05:20:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-24T02:33:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/09\/hero-10386-what-every-delete-command-really-rem-n.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Lukas Wojcik\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Lukas Wojcik\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/wordpress-plugins-tricks\\\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/wordpress-plugins-tricks\\\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\\\/\"},\"author\":{\"name\":\"Lukas Wojcik\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#\\\/schema\\\/person\\\/895f7604f9b6b71aad9bba33af28d0f9\"},\"headline\":\"WP-CLI Delete Commands: Which Tables Each One Touches and What It Leaves Behind\",\"datePublished\":\"2026-09-11T05:20:00+00:00\",\"dateModified\":\"2026-10-24T02:33:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/wordpress-plugins-tricks\\\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\\\/\"},\"wordCount\":980,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#\\\/schema\\\/person\\\/895f7604f9b6b71aad9bba33af28d0f9\"},\"image\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/wordpress-plugins-tricks\\\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/hero-10386-what-every-delete-command-really-rem-n.png\",\"keywords\":[\"MySQL\",\"WordPress\"],\"articleSection\":[\"WordPress Plugins &amp; Tricks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/wordpress-plugins-tricks\\\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/wordpress-plugins-tricks\\\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\\\/\",\"url\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/wordpress-plugins-tricks\\\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\\\/\",\"name\":\"WP-CLI Delete Commands: Which Tables Each One Touches and What It Leaves Behind | Lukas Wojcik\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/wordpress-plugins-tricks\\\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/wordpress-plugins-tricks\\\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/hero-10386-what-every-delete-command-really-rem-n.png\",\"datePublished\":\"2026-09-11T05:20:00+00:00\",\"dateModified\":\"2026-10-24T02:33:04+00:00\",\"description\":\"Revisions, transients, spam and orphaned meta: what each WP-CLI delete command actually removes, and the two-step pattern that replaces the missing dry run.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/wordpress-plugins-tricks\\\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/wordpress-plugins-tricks\\\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/wordpress-plugins-tricks\\\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/hero-10386-what-every-delete-command-really-rem-n.png\",\"contentUrl\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/hero-10386-what-every-delete-command-really-rem-n.png\",\"width\":1200,\"height\":630,\"caption\":\"WP-CLI Delete Commands: Which Tables Each One Touches and What It Leaves Behind\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/en\\\/wordpress-plugins-tricks\\\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WP-CLI Delete Commands: Which Tables Each One Touches and What It Leaves Behind\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/\",\"name\":\"Lukas Wojcik - Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#\\\/schema\\\/person\\\/895f7604f9b6b71aad9bba33af28d0f9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/#\\\/schema\\\/person\\\/895f7604f9b6b71aad9bba33af28d0f9\",\"name\":\"Lukas Wojcik\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/lw-x2.jpg\",\"url\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/lw-x2.jpg\",\"contentUrl\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/lw-x2.jpg\",\"width\":424,\"height\":636,\"caption\":\"Lukas Wojcik\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/lw-x2.jpg\"},\"sameAs\":[\"https:\\\/\\\/www.lukaswojcik.com\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WP-CLI Delete Commands: Which Tables Each One Touches and What It Leaves Behind | Lukas Wojcik","description":"Revisions, transients, spam and orphaned meta: what each WP-CLI delete command actually removes, and the two-step pattern that replaces the missing dry run.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/","og_locale":"en_US","og_type":"article","og_title":"WP-CLI Delete Commands: Which Tables Each One Touches and What It Leaves Behind | Lukas Wojcik","og_description":"Revisions, transients, spam and orphaned meta: what each WP-CLI delete command actually removes, and the two-step pattern that replaces the missing dry run.","og_url":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/","og_site_name":"Lukas Wojcik - Blog","article_published_time":"2026-09-11T05:20:00+00:00","article_modified_time":"2026-10-24T02:33:04+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/09\/hero-10386-what-every-delete-command-really-rem-n.png","type":"image\/png"}],"author":"Lukas Wojcik","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Lukas Wojcik","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/#article","isPartOf":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/"},"author":{"name":"Lukas Wojcik","@id":"https:\/\/www.lukaswojcik.com\/blog\/#\/schema\/person\/895f7604f9b6b71aad9bba33af28d0f9"},"headline":"WP-CLI Delete Commands: Which Tables Each One Touches and What It Leaves Behind","datePublished":"2026-09-11T05:20:00+00:00","dateModified":"2026-10-24T02:33:04+00:00","mainEntityOfPage":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/"},"wordCount":980,"commentCount":0,"publisher":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/#\/schema\/person\/895f7604f9b6b71aad9bba33af28d0f9"},"image":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/#primaryimage"},"thumbnailUrl":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/09\/hero-10386-what-every-delete-command-really-rem-n.png","keywords":["MySQL","WordPress"],"articleSection":["WordPress Plugins &amp; Tricks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/","url":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/","name":"WP-CLI Delete Commands: Which Tables Each One Touches and What It Leaves Behind | Lukas Wojcik","isPartOf":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/#primaryimage"},"image":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/#primaryimage"},"thumbnailUrl":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/09\/hero-10386-what-every-delete-command-really-rem-n.png","datePublished":"2026-09-11T05:20:00+00:00","dateModified":"2026-10-24T02:33:04+00:00","description":"Revisions, transients, spam and orphaned meta: what each WP-CLI delete command actually removes, and the two-step pattern that replaces the missing dry run.","breadcrumb":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/#primaryimage","url":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/09\/hero-10386-what-every-delete-command-really-rem-n.png","contentUrl":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/09\/hero-10386-what-every-delete-command-really-rem-n.png","width":1200,"height":630,"caption":"WP-CLI Delete Commands: Which Tables Each One Touches and What It Leaves Behind"},{"@type":"BreadcrumbList","@id":"https:\/\/www.lukaswojcik.com\/blog\/en\/wordpress-plugins-tricks\/wp-cli-delete-commands-which-tables-each-one-touches-and-what-it-leaves\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.lukaswojcik.com\/blog\/"},{"@type":"ListItem","position":2,"name":"WP-CLI Delete Commands: Which Tables Each One Touches and What It Leaves Behind"}]},{"@type":"WebSite","@id":"https:\/\/www.lukaswojcik.com\/blog\/#website","url":"https:\/\/www.lukaswojcik.com\/blog\/","name":"Lukas Wojcik - Blog","description":"","publisher":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/#\/schema\/person\/895f7604f9b6b71aad9bba33af28d0f9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.lukaswojcik.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.lukaswojcik.com\/blog\/#\/schema\/person\/895f7604f9b6b71aad9bba33af28d0f9","name":"Lukas Wojcik","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/07\/lw-x2.jpg","url":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/07\/lw-x2.jpg","contentUrl":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/07\/lw-x2.jpg","width":424,"height":636,"caption":"Lukas Wojcik"},"logo":{"@id":"https:\/\/www.lukaswojcik.com\/blog\/wp-content\/uploads\/2026\/07\/lw-x2.jpg"},"sameAs":["https:\/\/www.lukaswojcik.com\/blog"]}]}},"_links":{"self":[{"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/posts\/10386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/comments?post=10386"}],"version-history":[{"count":6,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/posts\/10386\/revisions"}],"predecessor-version":[{"id":23610,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/posts\/10386\/revisions\/23610"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/media\/15164"}],"wp:attachment":[{"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/media?parent=10386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/categories?post=10386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lukaswojcik.com\/blog\/wp-json\/wp\/v2\/tags?post=10386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}