Manual:templatelinks table
↑ Manual:Contents | <translate> MediaWiki database layout</translate> | <translate> <tvar name=1>templatelinks</tvar> table</translate> |
MediaWiki version: | <translate> ≥</translate> 1.6 |
The templatelinks table contains for each current transclusion the id of the host page, the namespace number of the included page, and its title without namespace.
The target page may or may not exist, and due to renames and deletions may refer to different page records as time goes by.
Despite the name, transclusions are not limited to templates, nor to the MediaWiki parser's transclusion mechanism; various extensions use this table to mark that they have incorporated content from another page.
(E.g. Scribunto 's {{#invoke:...}}
and TemplateStyles 's <templatestyles src="..." />
both record the target page in the templatelinks table.)
Fields
tl_from
Key to the page_id of the page doing the transclusion.
tl_namespace
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.38</tvar> is unsupported version</translate>"><translate> MediaWiki versions:</translate> |
Key to page_namespace of the page being transcluded page. Used in conjunction with tl_title.
tl_title
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.38</tvar> is unsupported version</translate>"><translate> MediaWiki versions:</translate> |
Key to page_title of the page being transcluded. Used in conjunction with tl_namespace.
tl_from_namespace
MediaWiki version: | <translate> ≥</translate> 1.24 |
page_namespace of the page doing the transclusion.
tl_target_id
<td class="mw-version-versionbox" title="<translate nowrap> The latest stable version is <tvar name=1>1.41</tvar></translate>"><translate> MediaWiki version:</translate> |
Foreign key to linktarget.lt_id
Schema summary
<td class="mw-version-versionbox" title="<translate nowrap> The latest stable version is <tvar name=1>1.41</tvar></translate>"><translate> MediaWiki version:</translate> |
DESCRIBE templatelinks;
+-------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------+-------+ | tl_from | int(10) unsigned | NO | PRI | 0 | | | tl_target_id | bigint(20) unsigned | NO | PRI | NULL | | | tl_from_namespace | int(11) | NO | MUL | 0 | | +-------------------+---------------------+------+-----+---------+-------+<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.38</tvar> is unsupported version</translate>">
<translate> MediaWiki version:</translate> |
DESCRIBE templatelinks;
+-------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------+-------+ | tl_from | int(10) unsigned | NO | PRI | 0 | | | tl_namespace | int(11) | NO | PRI | 0 | | | tl_title | varbinary(255) | NO | PRI | | | | tl_from_namespace | int(11) | NO | MUL | 0 | | | tl_target_id | bigint(20) unsigned | YES | MUL | NULL | | +-------------------+---------------------+------+-----+---------+-------+<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.37</tvar> is unsupported version</translate>">
<translate> MediaWiki versions:</translate> |
DESCRIBE templatelinks;
+-------------------+------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+------------------+------+-----+---------+-------+ | tl_from | int(10) unsigned | NO | PRI | 0 | | | tl_namespace | int(11) | NO | PRI | 0 | | | tl_title | varbinary(255) | NO | PRI | | | | tl_from_namespace | int(11) | NO | MUL | 0 | | +-------------------+------------------+------+-----+---------+-------+<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.35</tvar> is unsupported version</translate>">
<translate> MediaWiki versions:</translate> |
DESCRIBE templatelinks;
+-------------------+------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+------------------+------+-----+---------+-------+ | tl_from | int(10) unsigned | NO | PRI | 0 | | | tl_from_namespace | int(11) | NO | MUL | 0 | | | tl_namespace | int(11) | NO | PRI | 0 | | | tl_title | varbinary(255) | NO | PRI | | | +-------------------+------------------+------+-----+---------+-------+<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.25</tvar> is unsupported version</translate>">
<translate> MediaWiki versions:</translate> |
DESCRIBE templatelinks;
+-------------------+---------------------+------+-----+-----------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+-----------+-------+ | tl_from | int(10) unsigned | NO | PRI | 0 | | | tl_from_namespace | int(11) | NO | | 0 | | | tl_namespace | int(11) | NO | PRI | 0 | | | tl_title | varchar(255) binary | NO | PRI | 0 | | +-------------------+---------------------+------+-----+-----------+-------+<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.23</tvar> is unsupported version</translate>">
<translate> MediaWiki versions:</translate> |
DESCRIBE templatelinks;
+---------------+---------------------+------+-----+-----------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+-----------+-------+ | tl_from | int(10) unsigned | NO | PRI | 0 | | | tl_namespace | int(11) | NO | PRI | 0 | | | tl_title | varchar(255) binary | NO | PRI | 0 | | +---------------+---------------------+------+-----+-----------+-------+<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.9</tvar> is unsupported version</translate>">
<translate> MediaWiki versions:</translate> |
DESCRIBE templatelinks;
+---------------+---------------------+------+-----+-----------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+-----------+-------+ | tl_from | int(8) unsigned | NO | PRI | 0 | | | tl_namespace | int(8) | NO | PRI | 0 | | | tl_title | varchar(255) binary | NO | PRI | 0 | | +---------------+---------------------+------+-----+-----------+-------+
Indexes
<td class="mw-version-versionbox" title="<translate nowrap> The latest stable version is <tvar name=1>1.41</tvar></translate>"><translate> MediaWiki version:</translate> |
SHOW INDEX IN templatelinks;
+---------------+------------+----------------------------------+--------------+-------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +---------------+------------+----------------------------------+--------------+-------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | templatelinks | 0 | PRIMARY | 1 | tl_from | A | 0 | NULL | NULL | | BTREE | | | | templatelinks | 0 | PRIMARY | 2 | tl_target_id | A | 0 | NULL | NULL | | BTREE | | | | templatelinks | 1 | tl_target_id | 1 | tl_target_id | A | 0 | NULL | NULL | | BTREE | | | | templatelinks | 1 | tl_target_id | 2 | tl_from | A | 0 | NULL | NULL | | BTREE | | | | templatelinks | 1 | tl_backlinks_namespace_target_id | 1 | tl_from_namespace | A | 0 | NULL | NULL | | BTREE | | | | templatelinks | 1 | tl_backlinks_namespace_target_id | 2 | tl_target_id | A | 0 | NULL | NULL | | BTREE | | | | templatelinks | 1 | tl_backlinks_namespace_target_id | 3 | tl_from | A | 0 | NULL | NULL | | BTREE | | | +---------------+------------+----------------------------------+--------------+-------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+