Manual:Таблиця page

This page is a translated version of the page Manual:Page table and the translation is 37% complete.
Outdated translations are marked like this.
Посібник:Зміст MediaWiki database layout page table
Версія MediaWiki:
1.5

Таблиця page може вважатися "ядром вікі". Кожна сторінка в інсталяції MediaWiki має запис в цій таблиці, який ідентифікує цю сторінку за її назвою та містить деякі необхідні метадані. Таблиця була вперше запроваджена у r6710, в MediaWiki 1.5.

Текст сторінки зберігається в таблиці text . Щоб отримати текст статті, MediaWiki спочатку шукає page_title в таблиці page. Далі, використовується page_latest для для пошуку rev_id в revision table, і rev_text_id отримується в процесі. Отримане значення rev_text_id використовується для пошуку old_id в таблиці text щоб врешті отримати сам текст. Коли сторінку видаляють, її версії переміщаються до таблиці archive .

Якщо ви хочете повністю видалити сторінку вручну з бази даних, обов’язково видаліть запис для сторінки в таблиці сторінок, і для всіх версій сторінки в таблиці версій, а також усі текстові рядки, що відповідають тільки сторінці в текстовій таблиці. Це можна зробити, видаливши рядок сторінки, а потім запустивши maintenance/deleteOrphanedRevisions.php. Див. також нижче, як це зробити.

Поля

page_id

Унікально ідентифікує первинний ключ. Це значення зберігається незмінним під час редагувань та перейменувань.

Ідентифікатори сторінок (page IDs) не змінюються, коли сторінки переміщуються, але вони можуть змінюватися, коли сторінки видаляються, а потім відновлюються. Починаючи з MediaWiki 1.27, історичний ідентифікатор сторінки (page ID) зберігається в таблиці archive , а відновлені сторінки намагаються відновити свій старий ідентифікатор сторінки.

For further information, see:

page_namespace

Ім'я сторінки (page name) розбивається на простір назв (namespace) і назву сторінки (page title). The namespace keys are UI-language-independent constants, defined in includes/Defines.php.

This field contains the number of the page's namespace. The values range from 0 to 99 for the core namespaces, and from 100 to 10,000 for custom namespaces.

page_title

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.

page_is_redirect

A value of 1 here indicates the article is a redirect; it is 0 in all other cases.

page_is_new

This field stores whether the page is 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 new; otherwise, it is 0. Rollback links are not displayed if the page is new, since there is nothing to roll back to.

page_random

Random decimal value, between 0 and 1, used for Special:Random (see Manual:Random page for more details). Generated by wfRandom() .

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.

page_touched

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.

page_links_updated

Версія MediaWiki:
1.23

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() .

page_latest

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().

page_len

Uncompressed length in bytes of the page's current source text.

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.

page_content_model

Версія MediaWiki:
1.21

Content model, see CONTENT_MODEL_XXX constants. Comparable to revision.rev_content_model.

page_lang

Версія MediaWiki:
1.24

Page content language. Set to the default value of NULL at the time of page creation.

page_restrictions

Версія MediaWiki:
1.9

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").

Версії MediaWiki:
1.10 – 1.38
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. (removed in 1.39)

page_counter

Версія MediaWiki:
1.24

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.


Короткий опис схеми

Версія MediaWiki:
1.36
Gerrit change 690067

DESCRIBE page;

+--------------------+---------------------+------+-----+---------+----------------+
| Field              | Type                | Null | Key | Default | Extra          |
+--------------------+---------------------+------+-----+---------+----------------+
| page_id            | int(10) unsigned    | NO   | PRI | NULL    | auto_increment |
| page_namespace     | int(11)             | NO   | MUL | NULL    |                |
| page_title         | varbinary(255)      | NO   |     | NULL    |                |
| page_restrictions  | tinyblob            | YES  |     | NULL    |                |
| page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0       |                |
| page_is_new        | tinyint(3) unsigned | NO   |     | 0       |                |
| page_random        | double unsigned     | NO   | MUL | NULL    |                |
| page_touched       | binary(14)          | NO   |     | NULL    |                |
| page_links_updated | varbinary(14)       | YES  |     | NULL    |                |
| page_latest        | int(10) unsigned    | NO   |     | NULL    |                |
| page_len           | int(10) unsigned    | NO   | MUL | NULL    |                |
| page_content_model | varbinary(32)       | YES  |     | NULL    |                |
| page_lang          | varbinary(35)       | YES  |     | NULL    |                |
+--------------------+---------------------+------+-----+---------+----------------+
Версія MediaWiki:
1.35
Gerrit change 581141

DESCRIBE page;

+--------------------+---------------------+------+-----+----------------+----------------+
| Field              | Type                | Null | Key | Default        | Extra          |
+--------------------+---------------------+------+-----+----------------+----------------+
| page_id            | int(10) unsigned    | NO   | PRI | NULL           | auto_increment |
| page_namespace     | int(11)             | NO   | MUL | NULL           |                |
| page_title         | varbinary(255)      | NO   |     | NULL           |                |
| page_restrictions  | tinyblob            | YES  |     | NULL           |                |
| page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0              |                |
| page_is_new        | tinyint(3) unsigned | NO   |     | 0              |                |
| page_random        | double unsigned     | NO   | MUL | NULL           |                |
| page_touched       | binary(14)          | NO   |     |                |                |
| page_links_updated | varbinary(14)       | YES  |     | NULL           |                |
| page_latest        | int(10) unsigned    | NO   |     | NULL           |                |
| page_len           | int(10) unsigned    | NO   | MUL | NULL           |                |
| page_content_model | varbinary(32)       | YES  |     | NULL           |                |
| page_lang          | varbinary(35)       | YES  |     | NULL           |                |
+--------------------+---------------------+------+-----+----------------+----------------+
Версії MediaWiki:
1.25 – 1.34
Gerrit change 167655

DESCRIBE page;

+--------------------+---------------------+------+-----+----------------+----------------+
| Field              | Type                | Null | Key | Default        | Extra          |
+--------------------+---------------------+------+-----+----------------+----------------+
| page_id            | int(10) unsigned    | NO   | PRI | NULL           | auto_increment |
| page_namespace     | int(11)             | NO   | MUL | NULL           |                |
| page_title         | varbinary(255)      | NO   |     | NULL           |                |
| page_restrictions  | tinyblob            | NO   |     | NULL           |                |
| page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0              |                |
| page_is_new        | tinyint(3) unsigned | NO   |     | 0              |                |
| page_random        | double unsigned     | NO   | MUL | NULL           |                |
| page_touched       | binary(14)          | NO   |     |                |                |
| page_links_updated | varbinary(14)       | YES  |     | NULL           |                |
| page_latest        | int(10) unsigned    | NO   |     | NULL           |                |
| page_len           | int(10) unsigned    | NO   | MUL | NULL           |                |
| page_content_model | varbinary(32)       | YES  |     | NULL           |                |
| page_lang          | varbinary(35)       | YES  |     | NULL           |                |
+--------------------+---------------------+------+-----+----------------+----------------+
Версія MediaWiki:
1.24
Gerrit change 135312

DESCRIBE page;

+--------------------+---------------------+------+-----+---------+----------------+
| Field              | Type                | Null | Key | Default | Extra          |
+--------------------+---------------------+------+-----+---------+----------------+
| page_id            | int(10) unsigned    | NO   | PRI | NULL    | AUTO_INCREMENT |
| page_namespace     | int(11)             | NO   | MUL | NULL    |                |
| page_title         | varchar(255) binary | NO   |     | NULL    |                |
| page_restrictions  | tinyblob            | NO   |     | NULL    |                |
| page_counter       | bigint(20) unsigned | NO   |     | 0       |                |
| page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0       |                |
| page_is_new        | tinyint(3) unsigned | NO   |     | 0       |                |
| page_random        | real unsigned       | NO   | MUL | NULL    |                |
| page_touched       | binary(14)          | NO   |     | NULL    |                |
| page_links_updated | varbinary(14)       | YES  |     | NULL    |                |
| page_latest        | int(10) unsigned    | NO   |     | NULL    |                |
| page_len           | int(10) unsigned    | NO   | MUL | NULL    |                |
| page_content_model | varbinary(32)       | YES  |     | NULL    |                |
| page_lang          | varbinary(35)       | YES  |     | NULL    |                |
+--------------------+---------------------+------+-----+---------+----------------+
Версія MediaWiki:
1.23
Gerrit change 101170

DESCRIBE page;

+--------------------+---------------------+------+-----+---------+----------------+
| Field              | Type                | Null | Key | Default | Extra          |
+--------------------+---------------------+------+-----+---------+----------------+
| page_id            | int(10) unsigned    | NO   | PRI | NULL    | AUTO_INCREMENT |
| page_namespace     | int(11)             | NO   | MUL | NULL    |                |
| page_title         | varchar(255) binary | NO   |     | NULL    |                |
| page_restrictions  | tinyblob            | NO   |     | NULL    |                |
| page_counter       | bigint(20) unsigned | NO   |     | 0       |                |
| page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0       |                |
| page_is_new        | tinyint(3) unsigned | NO   |     | 0       |                |
| page_random        | real unsigned       | NO   | MUL | NULL    |                |
| page_touched       | binary(14)          | NO   |     | NULL    |                |
| page_links_updated | varbinary(14)       | YES  |     | NULL    |                |
| page_latest        | int(10) unsigned    | NO   |     | NULL    |                |
| page_len           | int(10) unsigned    | NO   | MUL | NULL    |                |
| page_content_model | varbinary(32)       | YES  |     | NULL    |                |
+--------------------+---------------------+------+-----+---------+----------------+
Версії MediaWiki:
1.21 – 1.22

DESCRIBE page;

+--------------------+---------------------+------+-----+---------+----------------+
| Field              | Type                | Null | Key | Default | Extra          |
+--------------------+---------------------+------+-----+---------+----------------+
| page_id            | int(10) unsigned    | NO   | PRI | NULL    | AUTO_INCREMENT |
| page_namespace     | int(11)             | NO   | MUL | NULL    |                |
| page_title         | varchar(255) binary | NO   |     | NULL    |                |
| page_restrictions  | tinyblob            | NO   |     | NULL    |                |
| page_counter       | bigint(20) unsigned | NO   |     | 0       |                |
| page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0       |                |
| page_is_new        | tinyint(3) unsigned | NO   |     | 0       |                |
| page_random        | real unsigned       | NO   | MUL | NULL    |                |
| page_touched       | binary(14)          | NO   |     | NULL    |                |
| page_latest        | int(10) unsigned    | NO   |     | NULL    |                |
| page_len           | int(10) unsigned    | NO   | MUL | NULL    |                |
| page_content_model | varbinary(32)       | YES  |     | NULL    |                |
+--------------------+---------------------+------+-----+---------+----------------+
Версії MediaWiki:
1.19 – 1.20

DESCRIBE page;

+-------------------+---------------------+------+-----+---------+----------------+
| Field             | Type                | Null | Key | Default | Extra          |
+-------------------+---------------------+------+-----+---------+----------------+
| page_id           | int(10) unsigned    | NO   | PRI | NULL    | AUTO_INCREMENT |
| page_namespace    | int(11)             | NO   | MUL | NULL    |                |
| page_title        | varchar(255) binary | NO   |     | NULL    |                |
| page_restrictions | tinyblob            | NO   |     | NULL    |                |
| page_counter      | bigint(20) unsigned | NO   |     | 0       |                |
| page_is_redirect  | tinyint(3) unsigned | NO   | MUL | 0       |                |
| page_is_new       | tinyint(3) unsigned | NO   |     | 0       |                |
| page_random       | real unsigned       | NO   | MUL | NULL    |                |
| page_touched      | binary(14)          | NO   |     | NULL    |                |
| page_latest       | int(10) unsigned    | NO   |     | NULL    |                |
| page_len          | int(10) unsigned    | NO   | MUL | NULL    |                |
+-------------------+---------------------+------+-----+---------+----------------+
Версії MediaWiki:
1.10 – 1.18

DESCRIBE page;

+-------------------+---------------------+------+-----+---------+----------------+
| Field             | Type                | Null | Key | Default | Extra          |
+-------------------+---------------------+------+-----+---------+----------------+
| page_id           | int(10) unsigned    | NO   | PRI | NULL    | AUTO_INCREMENT |
| page_namespace    | int(11)             | NO   | MUL | NULL    |                |
| page_title        | varchar(255) binary | NO   |     | NULL    |                |
| page_restrictions | tinyblob            | NO   |     | NULL    |                |
| page_counter      | bigint(20) unsigned | NO   |     | 0       |                |
| page_is_redirect  | tinyint(3) unsigned | NO   |     | 0       |                |
| page_is_new       | tinyint(3) unsigned | NO   |     | 0       |                |
| page_random       | real unsigned       | NO   | MUL | NULL    |                |
| page_touched      | binary(14)          | NO   |     | NULL    |                |
| page_latest       | int(10) unsigned    | NO   |     | NULL    |                |
| page_len          | int(10) unsigned    | NO   | MUL | NULL    |                |
+-------------------+---------------------+------+-----+---------+----------------+
Версії MediaWiki:
1.5 – 1.9

DESCRIBE page;

+-------------------+---------------------+------+-----+---------+----------------+
| Field             | Type                | Null | Key | Default | Extra          |
+-------------------+---------------------+------+-----+---------+----------------+
| page_id           | int(8) unsigned     | NO   | PRI | NULL    | AUTO_INCREMENT |
| page_namespace    | int(11)             | NO   | MUL | NULL    |                |
| page_title        | varchar(255) binary | NO   |     | NULL    |                |
| page_restrictions | tinyblob            | NO   |     | NULL    |                |
| page_counter      | bigint(20) unsigned | NO   |     | 0       |                |
| page_is_redirect  | tinyint(1) unsigned | NO   |     | 0       |                |
| page_is_new       | tinyint(1) unsigned | NO   |     | 0       |                |
| page_random       | real unsigned       | NO   | MUL | NULL    |                |
| page_touched      | char(14) binary     | NO   |     | NULL    |                |
| page_latest       | int(8) unsigned     | NO   |     | NULL    |                |
| page_len          | int(8) unsigned     | NO   | MUL | NULL    |                |
+-------------------+---------------------+------+-----+---------+----------------+

Індекси

Версія MediaWiki:
1.28

SHOW INDEX IN page;

+-------+------------+-----------------------------+--------------+------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name                    | Seq_in_index | Column_name      | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+-----------------------------+--------------+------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| page  |          0 | PRIMARY                     |            1 | page_id          | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| page  |          0 | page_name_title             |            1 | page_namespace   | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| page  |          0 | page_name_title             |            2 | page_title       | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| page  |          1 | page_random                 |            1 | page_random      | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| page  |          1 | page_len                    |            1 | page_len         | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| page  |          1 | page_redirect_namespace_len |            1 | page_is_redirect | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| page  |          1 | page_redirect_namespace_len |            2 | page_namespace   | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| page  |          1 | page_redirect_namespace_len |            3 | page_len         | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
+-------+------------+-----------------------------+--------------+------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

Приклади запитів на SQL

Список сторінок та їх зв'язків з іншими основними таблицями

Наступний запит вибере найостанніші версії всіх статей за умови, що стиснення або зовнішня пам’ять не використовуються:

SELECT page_id, page_namespace, page_title, page_latest "rev_id", old_text "text"
   FROM page
   INNER JOIN slots on page_latest = slot_revision_id
   INNER JOIN slot_roles on slot_role_id = role_id and role_name = 'main'
   INNER JOIN content on slot_content_id = content_id inner join text on substring( content_address, 4 ) = old_id and left( content_address, 3 ) = "tt:" and old_flags = "utf-8";

Інші важливі аспекти:

  • щоб знайти сторінки в просторі назв 0, додайте p.page_namespace = 0
  • щоб знайти сторінки, які не є перенаправленнями, додайте p.page_is_redirect = 0

Ці додаткові оператори можна додати або як умови до оператора Where, або як умови до відповідного оператора Inner Join.

Див. також