Wiki source code of Database Schema Names
Last modified by Eleni Cojocariu on 2026/11/25 14:43
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | Each wiki of an instance is stored in its own database schema. Two properties in ##xwiki/WEB-INF/xwiki.cfg## change how those schemas are named, for an instance that has to fit names someone else decides. Both are read at startup, so a change takes effect on the next restart. | ||
| 2 | |||
| 3 | |=Property|=What it names|=Applies to|=Shipped as | ||
| 4 | |##xwiki.db##|The schema of the main wiki|The main wiki only. Every other wiki keeps its own wiki id|Commented out, as ##xwiki.db=xwiki## | ||
| 5 | |##xwiki.db.prefix##|A prefix put in front of the schema name|**Every** wiki, the main wiki included|Commented out, empty | ||
| 6 | |||
| 7 | == The name a wiki gets when ##xwiki.db## is unset == | ||
| 8 | |||
| 9 | A sub-wiki's schema is its wiki id. The main wiki's is its wiki id too, ##xwiki## on a standard instance, except on the databases that reserve a schema of their own for it: | ||
| 10 | |||
| 11 | |=Database|=Schema of the main wiki | ||
| 12 | |HSQLDB|##PUBLIC## | ||
| 13 | |H2|##PUBLIC## | ||
| 14 | |Apache Derby|##APP## | ||
| 15 | |PostgreSQL, in schema mode, which is the default|##public## | ||
| 16 | |MySQL, MariaDB, Oracle|The wiki id | ||
| 17 | |||
| 18 | == The name you configure is not always the name that is used == | ||
| 19 | |||
| 20 | Whatever the two properties produce is adjusted before it reaches the database, and the adjustment applies to the prefix as well: | ||
| 21 | |||
| 22 | * **A hyphen becomes an underscore.** Many databases do not accept ##-## in a schema name, so a wiki whose id is ##my-wiki## is stored in ##my_wiki##. | ||
| 23 | * **Oracle, H2 and HSQLDB upper-case the result**, so the same wiki is ##MY_WIKI## there. | ||
| 24 | |||
| 25 | So the schema to look for in a database client is not necessarily the string written in ##xwiki.cfg## or the wiki id shown in the administration. | ||
| 26 | |||
| 27 | {{code language="none"}} | ||
| 28 | #-# [Since 1.6M1] | ||
| 29 | #-# Force the database name for the main wiki. | ||
| 30 | # xwiki.db=xwiki | ||
| 31 | |||
| 32 | #-# [Since 1.6M1] | ||
| 33 | #-# Add a prefix to all databases names of each wiki. | ||
| 34 | # xwiki.db.prefix= | ||
| 35 | {{/code}} |