The table wp_commentmeta
in WordPress database contains metadata for individual comments – mostly additional or optional bits of information, often created and used by plugins, that does not fit into the wp_comments
table. Examples include various comment rating scores or status information.
Table structure is similar to the other meta tables (wp_postmeta
, wp_termmeta
, wp_usermeta
).
Columns
meta_id
: Unique identifier for each metadata row (auto incrementing integer id). It has no other meaning.
comment_id
: The comment_ID from wp_comments
table. It identifies the comment which the metadata belongs to. Note different capitalization in the two tables: The column name is comment_id
here, but comment_ID
in wp_comments
.
meta_key
: Name (label) of the metadata. Maximum length is 255 characters. One comment can have multiple metadata rows, even multiple rows with the same meta_key
.
meta_value
: Value of the metadata. Although usually it is also quite short, its length can theoretically be very long (longtext = 2^32 characters). Often the value represents a number (such as a status or rating code), but it is always stored as text in the database (e.g. '1'
).
SQL Schema
CREATE TABLE `wp_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`comment_id` bigint(20) unsigned NOT NULL DEFAULT 0,
`meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`meta_value` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`meta_id`),
KEY `comment_id` (`comment_id`),
KEY `meta_key` (`meta_key`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;