Database Description/2.3

来自WordPress中文文档
Zhuozuran讨论 | 贡献2009年3月14日 (六) 09:23的版本 (1个修订)
跳转至: 导航搜索

The following is an outline and description of the database tables created during the standard installation of WordPress at Version 2.3.

Because WordPress interfaces with this database by itself, you as an end user, shouldn't have to worry much about its structure. If you're Writing a Plugin, however, you may be interested in learning how to interface with the database directly. WordPress provides the wpdb Class to make this task easy.

Table Overview

This section is the overview of all the tables created during the WordPress standard installation. It is followed by specific information of what is in each table.

strongWordPress 2.3 Tables (10)/strong
strongTable Name/strong strongDescription/strong strongRelevant Area(s) of WordPress User Interface/strong
wp_comments The comments within WordPress are stored in the ttwp_comments/tt table. Comments are created by readers as responses to posts. Comments are managed by administrator via Administration Panels gt;gt; Manage gt;gt; Comments
wp_links The ttwp_links/tt holds information related to the links entered into the Blogroll Manager feature of WordPress. Administration Panels gt;gt; Blogroll gt;gt; Manage Blogrollbr / Administration Panels gt;gt; Blogroll gt;gt; Add Linksbr / Administration Panels gt;gt; Blogroll gt;gt; Import Links
wp_options The Options set under the Administration Options panel are stored in the ttwp_options/tt table. Administration Panels gt;gt; Options gt; gt; Generalbr / Administration Panels gt;gt; Options gt; gt;Writingbr / Administration Panels gt;gt; Options gt; gt;Readingbr / Administration Panels gt;gt; Options gt; gt;Discussionbr / Administration Panels gt;gt; Options gt; gt;Permalinksbr / Administration Panels gt;gt; Options gt; gt;Miscellaneous
wp_postmeta Each post features information called the meta data and it is stored in the ttwp_postmeta/tt. Some tag plugins, and other plugins may add their own information to this table. Administration Panels gt;gt; Write gt;gt; Write a Post
wp_posts The core of the WordPress data is the posts. It is stored in the ttwp_posts/tt table. Administration Panels gt;gt; Write gt;gt; Write a Post
wp_terms The categories for both posts and links and the tags for posts are found within the ttwp_terms/tt table. Administration Panels gt;gt; Manage gt;gt; Categoriesbr /Administration Panels gt;gt; Write gt;gt; Write Postbr / Administration Panels gt;gt; Manage gt;gt; Posts gt;gt; Edit
wp_term_relationships Posts are associated with categories and tags from the ttwp_terms/tt table and this association is maintained in the ttwp_term_relationships/tt table. The association of links to their respective categories are also kept in this table. Administration Panels gt;gt; Manage gt;gt; Categoriesbr /Administration Panels gt;gt; Write gt;gt; Write Postbr / Administration Panels gt;gt; Manage gt;gt; Posts gt;gt; Edit
wp_term_taxonomy This table describes the taxonomy (category, link, or tag) for the entries in the ttwp_terms/tt table. Administration Panels gt;gt; Manage gt;gt; Categoriesbr /Administration Panels gt;gt; Write gt;gt; Write Postbr / Administration Panels gt;gt; Manage gt;gt; Posts gt;gt; Edit
wp_usermeta Each user features information called the meta data and it is stored in ttwp_usermeta/tt. Administration Panels gt;gt; Users
wp_users The list of users is maintained in table ttwp_users/tt. Administration Panels gt;gt; Users
br /br /

Table Details

The following are the specific fields in each of the tables created during the standard WordPress installation.

Table: wp_comments

Field Type Null Key Default Extra
comment_ID bigint(20) unsigned nbsp; PRI NULL auto_increment
comment_post_ID int(11) nbsp; IND 0 FK-gt;wp_posts.ID
comment_author tinytext nbsp; nbsp; nbsp; nbsp;
comment_author_email varchar(100) nbsp; nbsp; nbsp; nbsp;
comment_author_url varchar(200) nbsp; nbsp; nbsp; nbsp;
comment_author_IP varchar(100) nbsp; nbsp; nbsp; nbsp;
comment_date datetime nbsp; nbsp; 0000-00-00 00:00:00 nbsp;
comment_date_gmt datetime nbsp; nbsp; 0000-00-00 00:00:00 nbsp;
comment_content text nbsp; nbsp; nbsp; nbsp;
comment_karma int(11) nbsp; nbsp; 0 nbsp;
comment_approved enum('0','1','spam') nbsp; IND 1 nbsp;
comment_agent varchar(255) nbsp; nbsp; nbsp; nbsp;
comment_type varchar(20) nbsp; nbsp; nbsp; nbsp;
comment_parent bigint(20) nbsp; nbsp; 0 FK-gt;wp_comment.ID
user_id bigint(20) nbsp; nbsp; 0 FK-gt;wp_users.ID

Table: wp_links

Field Type Null Key Default Extra
link_id bigint(20) nbsp; PRI NULL auto_increment
link_url varchar(255) nbsp; nbsp; nbsp; nbsp;
link_name varchar(255) nbsp; nbsp; nbsp; nbsp;
link_image varchar(255) nbsp; nbsp; nbsp; nbsp;
link_target varchar(25) nbsp; nbsp; nbsp; nbsp;
link_category bigint(20) nbsp; IND 0 FK-gt;wp_categories.cat_ID
link_description varchar(255) nbsp; nbsp; nbsp; nbsp;
link_visible enum('Y','N') nbsp; IND Y nbsp;
link_owner int(11) nbsp; nbsp; 1 nbsp;
link_rating int(11) nbsp; nbsp; 0 nbsp;
link_updated datetime nbsp; nbsp; 0000-00-00 00:00:00 nbsp;
link_rel varchar(255) nbsp; nbsp; nbsp; nbsp;
link_notes mediumtext nbsp; nbsp; nbsp; nbsp;
link_rss varchar(255) nbsp; nbsp; nbsp; nbsp;


Table: wp_options

Field Type Null Key Default Extra
option_id bigint(20) nbsp; PRI NULL auto_increment
blog_id int(11) nbsp; PRI 0 nbsp;
option_name varchar(64) nbsp; PRIIND nbsp; nbsp;
option_can_override enum('Y','N') nbsp; nbsp; Y nbsp;
option_type int(11) nbsp; nbsp; 1 nbsp;
option_value longtext nbsp; nbsp; nbsp;
option_width int(11) nbsp; nbsp; 20 nbsp;
option_height int(11) nbsp; nbsp; 8 nbsp;
option_description tinytext nbsp; nbsp; nbsp;
option_admin_level int(11) nbsp; nbsp; 1 nbsp;
autoload enum('yes','no') nbsp; nbsp; yes nbsp;


Table: wp_postmeta

Field Type Null Key Default Extra
meta_id bigint(20) nbsp; PRI NULL auto_increment
post_id bigint(20) nbsp; IND 0 FK-gt;wp_posts.ID
meta_key varchar(255) YES IND NULL nbsp;
meta_value longtext YES nbsp; NULL nbsp;


Table: wp_posts

Field Type Null Key Default Extra
ID bigint(20) unsigned nbsp; PRI NULL auto_increment
post_author bigint(20) nbsp; nbsp; 0 FK-gt;wp_users.ID
post_date datetime nbsp; nbsp; 0000-00-00 00:00:00 nbsp;
post_date_gmt datetime nbsp; nbsp; 0000-00-00 00:00:00 nbsp;
post_content longtext nbsp; nbsp; nbsp; nbsp;
post_title text nbsp; nbsp; nbsp; nbsp;
post_category int(4) nbsp; nbsp; 0 FK-gt;wp_categories.cat_ID
post_excerpt text nbsp; nbsp; nbsp; nbsp;
post_status enum('publish','draft','private','static','object','attachment','inherit','future') nbsp; IND publish nbsp;
comment_status enum('open','closed','registered_only') nbsp; nbsp; open nbsp;
ping_status enum('open','closed') nbsp; nbsp; open nbsp;
post_password varchar(20) nbsp; nbsp; nbsp; nbsp;
post_name varchar(200) nbsp; IND nbsp; nbsp;
to_ping text nbsp; nbsp; nbsp; nbsp;
pinged text nbsp; nbsp; nbsp; nbsp;
post_modified datetime nbsp; nbsp; 0000-00-00 00:00:00 nbsp;
post_modified_gmt datetime nbsp; nbsp; 0000-00-00 00:00:00 nbsp;
post_content_filtered text nbsp; nbsp; nbsp;
post_parent bigint(20) nbsp; nbsp; 0 FK-gt;wp_posts.ID
guid varchar(255) nbsp; nbsp; nbsp; nbsp;
menu_order int(11) nbsp; nbsp; 0 nbsp;
post_type varchar(20) nbsp; nbsp; post nbsp;
post_mime_type varchar(100) nbsp; nbsp; nbsp; nbsp;
comment_count bigint(20) nbsp; nbsp; 0 nbsp;

Table: wp_terms

Field Type Null Key Default Extra
term_id bigint(20) nbsp; PRI nbsp; auto_increment
name varchar(55) nbsp; nbsp; nbsp; nbsp;
slug varchar(200) nbsp; UNI IND nbsp; nbsp;
term_group bigint(10) nbsp; nbsp; 0 nbsp;

Table: wp_term_relationships

Field Type Null Key Default Extra
object_id bigint(20) nbsp; PRI Pt1 0 nbsp;
term_taxonomy_id bigint(20) nbsp; PRI Pt2, IND 0 FK-gt;wp_term_taxonomy.term_taxonomy_id

Table: wp_term_taxonomy

Field Type Null Key Default Extra
term_taxonomy_id bigint(20) nbsp; PRI nbsp; auto_increment
term_id bigint(20) nbsp; UNI IND Pt1 0 FK-gt;wp_terms.term_id
taxonomy varchar(32) nbsp; UNI IND Pt2 nbsp; nbsp;
description longtext nbsp; nbsp; nbsp; nbsp;
parent bigint(20) nbsp; nbsp; 0 nbsp;
count bigint(20) nbsp; nbsp; 0 nbsp;

Table: wp_usermeta

Field Type Null Key Default Extra
umeta_id bigint(20) nbsp; PRI NULL auto_increment
user_id bigint(20) nbsp; nbsp; '0' FK-gt;wp_users.ID
meta_key varchar(255) nbsp; IND NULL nbsp;
meta_value longtext nbsp; IND NULL nbsp;


Table: wp_users

Field Type Null Key Default Extra
ID bigint(20) unsigned nbsp; PRI NULL auto_increment
user_login varchar(60) nbsp; UNI IND nbsp; nbsp;
user_pass varchar(64) nbsp; nbsp; nbsp; nbsp;
user_nicename varchar(50) nbsp; nbsp; nbsp; nbsp;
user_email varchar(100) nbsp; nbsp; nbsp; nbsp;
user_url varchar(100) nbsp; nbsp; nbsp; nbsp;
user_registered datetime nbsp; nbsp; 0000-00-00 00:00:00 nbsp;
user_level int(2) unsigned nbsp; nbsp; 0 nbsp;
user_activation_key varchar(60) nbsp; nbsp; nbsp;
user_status int(11) nbsp; nbsp; 0 nbsp;
display_name varchar(250) nbsp; nbsp; nbsp; nbsp;

Resources