ページ名検討中: このページ名「データベース構造」について改名が提案されています。ご意見をお寄せください。(2008-11-14)
以下は、WordPress バージョン 2.8 の標準的なインストールで作成されるデータベース・テーブルの概要と説明です。現在、WordPress バージョン 2.8 が対応しているデータベースは、MySQL バージョン 4.0 以上のみです。
WordPress は内部でデータベースと連動しているため、エンドユーザはその構造を気にかける必要はありません。しかしながら、プラグインを作るならば、データベースと直接連結する方法に興味を持つことでしょう。WordPress は wpdb クラス/en 関数を提供して、この作業が簡単になるようにしています。
注:
- テーブル名の接頭辞(
wp_
)は、WordPress インストール時の設定によります。
- プラグインやテーマによって、設定データの追加、既存テーブルへのフィールド追加、新規テーブル作成がなされることがあります。
- 旧バージョンのデータベース概要
Database Diagram
The diagram below provides a visual overview of the Wordpress database and the relations between the tables (WP Version 2.5+) created during the WordPress standard installation. The Table Overview below includes additional details on the tables and columns.
(WP 2.7 Database diagram) /英語版で画像を見る
Please note that within the standard installation of Wordpress no integrity between the tables is enforced e.g. between posts and comments. If you are creating a plugin or extension that manipulates the Wordpress database, your code should do the housekeeping so that no orphan records remain in the tables e.g. by removing records in other tables with a set of SQL commands when foreign keys are deleted (Don't forget to remind users to backup before such operations).
テーブル一覧
WordPress の標準インストールで作成される全テーブルの一覧です。各テーブルが持つ具体的な情報は次節をご覧ください。
テーブル詳細
WordPress の標準インストールで作成される各テーブルの項目一覧です。
フィールド |
タイプ |
Null |
キー |
初期値 |
備考 |
説明
|
comment_ID |
bigint(20) unsigned |
|
PRI |
NULL |
auto_increment |
コメントID(投稿順に自動採番)
|
comment_post_ID |
bigint(20) unsigned |
|
IND |
0 |
FK->wp_posts.ID |
コメントが属する投稿ID
|
comment_author |
tinytext |
|
|
|
|
コメント投稿者
|
comment_author_email |
varchar(100) |
|
|
|
|
コメント投稿者の Eメールアドレス
|
comment_author_url |
varchar(200) |
|
|
|
|
コメント投稿者のウェブサイトURL
|
comment_author_IP |
varchar(100) |
|
|
|
|
コメント投稿者の IPアドレス
|
comment_date |
datetime |
|
|
0000-00-00 00:00:00 |
|
コメント投稿日時
|
comment_date_gmt |
datetime |
|
IND & IND Pt2 |
0000-00-00 00:00:00 |
|
コメント投稿日時(GMT)
|
comment_content |
text |
|
|
|
|
コメント内容
|
comment_karma |
int(11) |
|
|
0 |
|
|
comment_approved |
varchar(20) |
|
IND & Ind Pt1 |
1 |
|
コメントの承認状態
-
'0' : 承認待ち
-
'1' : 承認済み
-
'spam' : スパム
|
comment_agent |
varchar(255) |
|
|
|
|
コメント投稿者のユーザエージェント
|
comment_type |
varchar(20) |
|
|
|
|
コメントの種類
-
'trackback' : トラックバック
-
'pingback' : ピンバック
- 通常コメントは値なし
|
comment_parent |
bigint(20) unsigned |
|
|
0 |
FK->wp_comments.ID
|
user_id |
bigint(20) unsigned |
|
|
0 |
FK->wp_users.ID |
コメント投稿者が登録ユーザであるとき、そのユーザID
|
インデックス
キー名 |
種別 |
Cardinality |
フィールド
|
PRIMARY |
PRIMARY |
1 |
comment_ID
|
comment_approved |
INDEX |
None |
comment_approved
|
comment_post_ID |
INDEX |
None |
comment_post_ID
|
comment_approved_date_gmt |
INDEX |
None |
comment_approved comment_date_gmt
|
comment_date_gmt |
INDEX |
None |
comment_date_gmt
|
テーブル: wp_links
フィールド |
タイプ |
Null |
キー |
初期値 |
備考 |
説明
|
link_id |
bigint(20) unsigned |
|
PRI |
NULL |
auto_increment |
リンクID(登録順に自動採番)
|
link_url |
varchar(255) |
|
|
|
|
リンク URL
|
link_name |
varchar(255) |
|
|
|
|
リンク名
|
link_image |
varchar(255) |
|
|
|
|
リンク画像の URI
|
link_target |
varchar(25) |
|
|
|
|
リンクターゲット
|
link_description |
varchar(255) |
|
|
|
|
説明
|
link_visible |
varchar(20) |
|
IND |
Y |
|
|
link_owner |
bigint(20) unsigned |
|
|
1 |
|
link_rating |
int(11) |
|
|
0 |
|
評価
|
link_updated |
datetime |
|
|
0000-00-00 00:00:00 |
|
link_rel |
varchar(255) |
|
|
|
|
link_notes |
mediumtext |
|
|
|
|
メモ
|
link_rss |
varchar(255) |
|
|
|
|
リンクのフィード URI
|
インデックス
キー名 |
種別 |
Cardinality |
フィールド
|
PRIMARY |
PRIMARY |
7 |
link_ID
|
link_category |
INDEX |
None |
link_category
|
link_visible |
INDEX |
None |
link_visible
|
テーブル: wp_options
フィールド |
タイプ |
Null |
キー |
初期値 |
備考 |
説明
|
option_id |
bigint(20) unsigned |
|
PRI Pt1 |
NULL |
auto_increment
|
blog_id |
int(11) |
|
PRI Pt2 |
0 |
|
option_name |
varchar(64) |
|
PRI Pt3 & IND |
|
|
option_value |
longtext |
|
|
|
|
autoload |
varchar(20) |
|
|
yes |
|
|
インデックス
キー名 |
種別 |
Cardinality |
フィールド
|
PRIMARY |
PRIMARY |
184 |
option_id blog_id option_name
|
option_name |
INDEX |
184 |
option_name
|
テーブル: wp_postmeta
フィールド |
タイプ |
Null |
キー |
初期値 |
備考 |
説明
|
meta_id |
bigint(20) unsigned |
|
PRI |
NULL |
auto_increment |
メタデータのユニークID
|
post_id |
bigint(20) unsigned |
|
IND |
0 |
FK->wp_posts.ID |
投稿記事ID
|
meta_key |
varchar(255) |
YES |
IND |
NULL |
|
カスタムフィールドのキー名
|
meta_value |
longtext |
YES |
|
NULL |
|
カスタムフィールドの値
|
インデックス
キー名 |
種別 |
Cardinality |
フィールド
|
PRIMARY |
PRIMARY |
13 |
meta_ID
|
post_id |
INDEX |
15 |
post_id
|
meta_key |
INDEX |
7 |
meta_key
|
テーブル: wp_posts
フィールド |
タイプ |
Null |
キー |
初期値 |
備考 |
説明
|
ID |
bigint(20) unsigned |
|
PRI & IND Pt4 |
|
auto_increment |
投稿ID(保存順に自動採番)
|
post_author |
bigint(20) unsigned |
|
|
0 |
FK->wp_users.ID |
投稿者のユーザID
|
post_date |
datetime |
|
IND Pt3 |
0000-00-00 00:00:00 |
|
投稿日時
|
post_date_gmt |
datetime |
|
|
0000-00-00 00:00:00 |
|
投稿日時(GMT)
|
post_content |
longtext |
|
|
|
|
本文
|
post_title |
text |
|
|
|
|
タイトル
|
post_excerpt |
text |
|
|
|
|
抜粋オプション
|
post_status |
varchar(20) |
|
IND PT2 |
publish |
|
投稿ステータス
-
'publish' : 公開済み
-
'pending' : ペンディング
-
'draft' : 草稿
-
'private' : プライベート(非公開)
-
'static' :(2.0.x 以前はページ)
-
'object' :
-
'attachment' :
-
'inherit' : 継承(添付ファイル、改訂履歴・自動保存のとき)
-
'future' : 予約投稿
|
comment_status |
varchar(20) |
|
|
open |
|
コメントステータス
-
'open' : 許可
-
'closed' : 不許可
-
'registered_only' : 登録ユーザのみ
|
ping_status |
varchar(20) |
|
|
open |
|
ピン・ステータス
-
'open' : トラックバック・ピンバックを受け付ける
-
'closed' : 受け付けない
|
post_password |
varchar(20) |
|
|
|
|
閲覧パスワード
|
post_name |
varchar(200) |
|
IND |
|
|
- 投稿スラッグ
-
'{親ID}-revision(-#)' (改訂履歴のとき)
-
'{親ID}-autosave' (自動保存のとき)
|
to_ping |
text |
|
|
|
|
pinged |
text |
|
|
|
|
ピン通知済み URL
|
post_modified |
datetime |
|
|
0000-00-00 00:00:00 |
|
更新日時
|
post_modified_gmt |
datetime |
|
|
0000-00-00 00:00:00 |
|
更新日時(GMT)
|
post_content_filtered |
text |
|
|
|
|
|
post_parent |
bigint(20) unsigned |
|
|
0 |
FK->wp_posts.ID |
親ID
- 親ページの投稿ID
- 添付ファイルが属する投稿ID
- 改訂履歴・自動保存のベース投稿ID
|
guid |
varchar(255) |
|
|
|
|
menu_order |
int(11) |
|
|
0 |
|
ページの表示順
|
post_type |
varchar(20) |
|
IND Pt1 |
post |
|
投稿種別
-
'post' : 投稿
-
'page' : ページ
-
'attachment' : 添付ファイル
-
'revision' : 改訂履歴・自動保存
|
post_mime_type |
varchar(100) |
|
|
|
|
添付ファイルのとき MIMEタイプ(image/png など)
|
comment_count |
bigint(20) |
|
|
0 |
|
コメント数
|
インデックス
キー名 |
種別 |
Cardinality |
フィールド
|
PRIMARY |
PRIMARY |
2 |
ID
|
post_name |
INDEX |
None |
post_name
|
type_status_date |
INDEX |
None |
post_type post_status post_date ID
|
post_parent |
INDEX |
None |
post_parent
|
テーブル: wp_terms
フィールド |
タイプ |
Null |
キー |
初期値 |
備考 |
説明
|
term_id |
bigint(20) unsigned |
|
PRI |
|
auto_increment |
term のユニークID
|
name |
varchar(200) |
|
|
|
|
term 名
|
slug |
varchar(200) |
|
UNI |
|
|
term スラッグ。term 名を URL で扱いやすい形にしたもの
|
term_group |
bigint(10) |
|
|
0 |
|
類義語のグルーピング
|
インデックス
キー名 |
種別 |
Cardinality |
フィールド
|
PRIMARY |
PRIMARY |
2 |
term_ID
|
slug |
UNIQUE |
2 |
slug
|
name |
Index |
none |
name
|
テーブル: wp_term_relationships
フィールド |
タイプ |
Null |
キー |
初期値 |
備考 |
説明
|
object_id |
bigint(20) unsigned |
|
PRI Pt1 |
0 |
|
記事ID or リンクID
|
term_taxonomy_id |
bigint(20) unsigned |
|
PRI Pt2 & IND |
0 |
FK->wp_term_taxonomy.term_taxonomy_id |
term_taxonomy テーブルの term_taxonomy_id
|
term_order |
int(11) |
|
|
0 |
|
|
インデックス
キー名 |
種別 |
Cardinality |
フィールド
|
PRIMARY |
PRIMARY |
8 |
object_id term_taxonomy_id
|
term_taxonomy_id |
INDEX |
None |
term_taxonomy_id
|
テーブル: wp_term_taxonomy
フィールド |
タイプ |
Null |
キー |
初期値 |
備考 |
説明
|
term_taxonomy_id |
bigint(20) unsigned |
|
PRI |
|
auto_increment |
term+taxonomy ペアのユニークID
|
term_id |
bigint(20) unsigned |
|
UNI Pt1 |
0 |
FK->wp_terms.term_id |
wp_terms テーブルの term_id
|
taxonomy |
varchar(32) |
|
UNI Pt2 |
|
|
term が属する taxonomy
-
'category' : 記事カテゴリ
-
'link_category' : リンクカテゴリ
-
'post_tag' : タグ
|
description |
longtext |
|
|
|
|
term の分類上の説明。「カテゴリ説明」など
|
parent |
bigint(20) unsigned |
|
|
0 |
|
分類上の term 間の上下関係
|
count |
bigint(20) |
|
|
0 |
|
term+taxonomy ペアに関連付けられたオブジェクト数。taxonomy='category' であればこのカテゴリに属する投稿記事数
|
インデックス
キー名 |
種別 |
Cardinality |
フィールド
|
PRIMARY |
PRIMARY |
2 |
term_taxonomy_id
|
term_id_taxonomy |
UNIQUE |
2 |
term_id taxonomy
|
taxonomy |
INDEX |
None |
taxonomy
|
テーブル: wp_usermeta
フィールド |
タイプ |
Null |
キー |
初期値 |
備考 |
説明
|
umeta_id |
bigint(20) unsigned |
|
PRI |
NULL |
auto_increment |
ユーザ・メタデータの ID(登録順に自動採番)
|
user_id |
bigint(20) unsigned |
|
IND |
'0' |
FK->wp_users.ID |
wp_users テーブルのユーザID
|
meta_key |
varchar(255) |
YES |
IND |
NULL |
|
ユーザ・メタデータのキー名(wp_capabilities など)
|
meta_value |
longtext |
YES |
|
NULL |
|
値
|
インデックス
キー名 |
種別 |
Cardinality |
フィールド
|
PRIMARY |
PRIMARY |
9 |
umeta_id
|
user_id |
INDEX |
None |
user_id
|
meta_key |
INDEX |
None |
meta_key
|
テーブル: wp_users
フィールド |
タイプ |
Null |
キー |
初期値 |
備考 |
説明
|
ID |
bigint(20) unsigned |
|
PRI |
NULL |
auto_increment |
ユーザID
|
user_login |
varchar(60) |
|
IND |
|
|
ログイン名
|
user_pass |
varchar(64) |
|
|
|
|
パスワード(暗号化)
|
user_nicename |
varchar(50) |
|
IND |
|
|
|
user_email |
varchar(100) |
|
|
|
|
Eメールアドレス
|
user_url |
varchar(100) |
|
|
|
|
webサイト URI
|
user_registered |
datetime |
|
|
0000-00-00 00:00:00 |
|
登録日時
|
user_level |
int(2) unsigned |
|
|
0 |
|
|
user_activation_key |
varchar(60) |
|
|
|
|
|
user_status |
int(11) |
|
|
0 |
|
|
display_name |
varchar(250) |
|
|
|
|
表示名
|
インデックス
キー名 |
種別 |
Cardinality |
フィールド
|
PRIMARY |
PRIMARY |
1 |
ID
|
user_login_key |
INDEX |
None |
user_login
|
user_nicename |
INDEX |
None |
user_nicename
|
Resources
旧バージョンのデータベース概要
変更履歴
- 2.8 :
- comments テーブル:
comment_post_ID
フィールドが int(11)
から bigint(20) unsigned
へ変更されました。
- links テーブル:
-
link_category
フィールドが削除されました。
-
link_owner
フィールドが int(11)
から bigint(20) unsigned
へ変更されました。
- posts テーブル:
-
post_category
フィールドが削除されました。
- 草稿データにも
post_date
を格納するようになりました。
- term_taxonomy テーブル: KEY に
taxonomy
が追加されました。
- ほとんどの
bigint(20)
フィールドに unsigned
属性が追加されました。
(commentsテーブル)comment_parent
, user_id
, (linksテーブル)link_id
, (optionsテーブル)option_id
, (metaテーブル)meta_id
, post_id
, (postsテーブル)post_author
, post_parent
, (termsテーブル)term_id
, (term_relationshipsテーブル)object_id
, term_taxonomy_id
, (term_taxonomyテーブル)term_taxonomy_id
, term_id
, parent
, (usermetaテーブル)umeta_id
, user_id
- 2.7 :
- 2.6 : 投稿の改訂履歴データを持つようになりました。
- 2.5 :
- 2.3 :
-
categories
、link2cat
、post2cat
テーブル廃止、terms
、term_taxonomy
、term_relationships
テーブル追加。
- options テーブルより 6フィールド削除。(
option_can_override
, option_type
, option_width
, option_height
, option_description
, option_admin_level
)
- posts テーブルの
post_status
フィールドに新規ステータス 'pending'
を追加。
- 参考: プラグインとテーマの移行 - 2.2 から 2.3 への移行
- 2.1 :
最新英語版: WordPress Codex » Database Description (最新版との差分)