How to Find Which WordPress Plugin or Theme Made a Database Table

An unfamiliar table in a WordPress database almost always belongs to a plugin or theme that creates its own storage, and you can usually identify the owner by matching the table name against the plugin's code. The wordpress database table plugin question is really a code search problem: find the string, find the file, and the file path tells you the owner. The table prefix and naming conventions narrow the field first, then a search through the plugins and themes directories confirms it.

Start with the table name and the prefix

WordPress prefixes core tables with the value of $table_prefix in wp-config.php, so core tables look like wp_posts, wp_options and wp_users. Plugins usually follow the same convention and append their own slug, giving names such as wp_woocommerce_sessions or wp_myplugin_log. That slug is your first clue, but it is not proof: a plugin can register tables under any name it likes, including names that imitate core tables or share a prefix with another plugin.

List the tables and note the prefix in use:

$ wp db query "SHOW TABLES" --allow-root
+------------------------+
| Tables_in_wordpress    |
+------------------------+
| wp_commentmeta         |
| wp_comments            |
| wp_myplugin_queue      |
| wp_options             |
| wp_posts               |
+------------------------+

If the unfamiliar table carries the same prefix as core tables, the plugin is using $wpdb->prefix or a hardcoded prefix, and the suffix is the part to search for. If it uses a different prefix, for example shop_, the plugin may be building the name from a constant or an option, which means searching for the suffix alone is often more productive than searching for the full name.

Search the plugin and theme code for the table name

The reliable method is a recursive grep across wp-content/plugins and wp-content/themes. Search for the distinctive part of the table name, not the prefix, because the prefix is often concatenated at runtime. Use grep -r with fixed strings and line numbers so you can open the exact file:

$ grep -rn --include='*.php' 'myplugin_queue' wp-content/plugins wp-content/themes
wp-content/plugins/my-plugin/includes/class-queue.php:42: $table = $wpdb->prefix . 'myplugin_queue';

The path in the output tells you the owner directly. If the match is inside wp-content/plugins/acme-tools/, the table belongs to that plugin. If it is inside a theme, the theme is creating it, which is less common but does happen for themes that store cached data or custom post meta in their own tables. When the search returns nothing, the table name is being assembled dynamically. In that case search for the suffix fragment, or search for the function that creates tables, dbDelta, and read the schema definitions it receives.

For a plugin with many files, restrict the search to PHP and skip minified assets, which will otherwise flood the output. The --include flag above does that. If you have rg available, rg -n 'myplugin_queue' wp-content/plugins is faster and respects ignore files, but plain grep is present on every server you are likely to touch.

Use the database itself when the code search is inconclusive

Plugins that create tables usually record the schema version in the options table, and that record often names the plugin. Look for rows whose option name contains the table suffix:

$ wp db query "SELECT option_name, option_value FROM wp_options WHERE option_name LIKE '%myplugin%'"
+---------------------------+---------------+
| option_name               | option_value  |
+---------------------------+---------------+
| myplugin_db_version       | 3             |
| myplugin_settings         | a:2:{...}     |
+---------------------------+---------------+

A row like myplugin_db_version is strong evidence that a plugin named myplugin owns the table, since the version option is what the plugin checks before running dbDelta to create or alter its schema. You can also inspect the table structure: a column named after a plugin slug, or a foreign key style column such as order_id pointing at another plugin's data, narrows the owner. The SHOW CREATE TABLE statement gives you comments and column names in one go:

$ wp db query "SHOW CREATE TABLE wp_myplugin_queue\G"

Look at the table comment and the column names. Many plugins record their own name in the table comment when they create it, and even when they do not, the column names usually echo the plugin's domain model. Combine that with the grep result and you have enough to act.

Confirm the owner before you delete anything

Identification and deletion are separate decisions. A table may be orphaned because the plugin was uninstalled without running its uninstall routine, or it may still be in active use by a plugin that is installed but currently deactivated. Check the plugin list and the active theme before removing rows or dropping tables:

$ wp plugin list --status=inactive
$ wp theme list --status=active

If the owning plugin is still installed, even deactivated, the safe move is to let the plugin remove its own data through its uninstall handler, or to reactivate it and use its own cleanup option. Dropping a table that a deactivated plugin expects to find will cause errors the moment it is reactivated. If the plugin is gone entirely and the table is confirmed orphaned, take a database dump before dropping anything, keep the dump until you are sure nothing breaks, and drop the table only after the site has run normally for a while without it.

Next step: run the grep against your plugins and themes directories with the suffix of the mystery table, open the file that matches, and read the dbDelta call or the $wpdb->prefix concatenation to confirm the owner. If the search finds nothing, query wp_options for the suffix and inspect SHOW CREATE TABLE before concluding the table is orphaned. Write down what you found in your notes so the next person who sees the table does not have to repeat the investigation.

Related articles

Subscribe to our newsletter

Get the latest hosting tips, performance insights, and industry news.