Manual:page table

Contents

MediaWiki version:

≥ 1.5

The page table can be considered the "core of the wiki".
Each page in a MediaWiki installation has an entry here which identifies it by title and contains some essential metadata.
It was first introduced in r6710, in MediaWiki 1.5.

The text of the page itself is stored in the text table.
To retrieve the text of an article, MediaWiki first searches for page_title in the page table.
Then, page_latest is used to search the revision table for rev_id, and rev_text_id is obtained in the process.
The value obtained for rev_text_id is used to search for old_id in the text table to retrieve the text.
When a page is deleted, the revisions are moved to the archive table.

If you want to completely delete a page manually from the database, be sure to delete the entry for the page in the page table, and for all the page's revisions in the revision table, and all of the text rows corresponding only to the page in the text table. This can be done by deleting the page row, then running maintenance/deleteOrphanedRevisions.php. See also title Deleting pages with their relationships in text and revision tables below how to do.

Uniquely identifying primary key.
This value is preserved across edits and renames.

Page IDs do not change when pages are moved, but they do change when pages are deleted and then restored.
As of MediaWiki 1.27, this value is still 'preserved' across deletions via an analogous field in the archive table (introduced in MediaWiki 1.11).

MediaWiki offers a number of relevant tools:

The page ID of any page (except special pages) can be looked up in the "page information" link from the Tools menu.

The magic word {{PAGEID}} can be used to return the page id of a page.

The sanitized page title, without the namespace, with a maximum of 255 characters (binary).
It is stored as text, with spaces replaced by underscores.
The real title shown in articles is just this title with underscores (_) converted to spaces ( ).
For example, a page titled "Talk:Foo Bar" would have "Foo_Bar" in this field.

Comma-separated set of permission keys indicating who can move or edit the page.
Edit and move sections are separated by a colon (e.g., "edit=autoconfirmed,sysop:move=sysop").

Beginning with MediaWiki 1.10, page protection controls were moved to the page restrictions table, so this field will be empty in databases generated by more current versions of MediaWiki. However, this field is still used in current versions of MediaWiki for rows generated by older versions of MediaWiki!

Number of times the page has been viewed.
This feature was completely removed in MediaWiki 1.25, following a request for comment.
Even before that, many sites including Wikimedia projects disabled it to increase performance; see Manual:$wgDisableCounters for details.

This field stores whether the page is a new, meaning it either has only one revision or has not been edited since being restored, even if there is more than one revision.
If the field contains a value of 1, then it indicates that the page is a new; otherwise, it is 0.
Rollback links are not displayed if the page is new, since there is nothing to roll back to.

Around 2005, a bug caused these random values to be non-uniform. Since the field is set at page creation, wikis that have existed for a long time might still have some of these erroneous values. See T208909.

This timestamp is updated whenever the page changes in a way requiring it to be re-rendered, invalidating caches.
Aside from editing, this includes permission changes, creation or deletion of linked pages, and alteration of contained templates.
Set to $dbw->timestamp() at the time of page creation.

This timestamp is updated whenever a page is re-parsed and it has all the link tracking tables updated for it.
This is useful for de-duplicating expensive backlink update jobs.
Set to the default value of NULL when the page is created by WikiPage::insertOn().

This is a foreign key to rev_id for the current revision.
It may be 0 during page creation.
It needs to link to a revision with a valid revision.rev_page, or there will be the "The revision #0 of the page named 'Foo' does not exist" error when one tries to view the page.
Can be obtained via WikiPage::getLatest().

This however, does not apply to images which still have records in this table.
Instead, the uncompressed length in bytes of the description for the file is used as the latter is in the text.old_text field.

The Wikipage class in includes/WikiPage.php has two methods, viz., insertOn() and updateRevisionOn() that are responsible for populating these details.

These additional statements can be added either as conditions to a Where statement or as conditions on the appropriate Inner Join statement.

Deleting pages with their relationships in text and revision tablesEdit

The following shows the steps to run to help you delete pages and their children from the main pages in the page, revision and text tables.

Listing all related table keys

-- -- Listing page titles and related relationships to other tables (revision, text, page)--SELECT`p`.`page_id`AS"page_id",CAST(`p`.`page_title`ASCHAR(10000)CHARACTERSETutf8)AS"page_title",`r`.`rev_text_id`AS"revision_id",`t`.`old_id`AS"text_id"FROMpagepINNERJOIN`revision`rON`p`.`page_id`=`r`.`rev_page`-- Confirmed to be reference to page.page_idINNERJOIN`text`tON`r`.`rev_text_id`=`t`.`old_id`-- Confirmed to be reference to revision tableWHERE`p`.`page_title`LIKE'%Tests/parent-a%';-- Match with title of a parent page

Deleting from database the rows

-- -- Making a comma separated list of each table ids to delete, Will be used in a delete transaction--SELECTCONCAT('IN(',GROUP_CONCAT(`p`.`page_id`),')')AS'page',CONCAT('IN(',GROUP_CONCAT(`r`.`rev_text_id`),')')AS'revision',CONCAT('IN(',GROUP_CONCAT(`t`.`old_id`),')')AS'text'FROMpagepINNERJOIN`revision`rON`p`.`page_id`=`r`.`rev_page`-- Confirmed to be reference to page.page_idINNERJOINtexttON`r`.`rev_text_id`=`t`.`old_id`-- Confirmed to be reference to revision tableWHEREp.page_titleLIKE'%Tests/parent-a%';-- Match with title of a parent page