The body of content.xml is office:database. Its children, in the order the OpenDocument 1.3
schema (part 1 chapter 12, and the RELAX NG schema) allows them, are db:data-source,
db:forms, db:reports, db:queries, db:table-representations and
db:schema-definition. The first is described here; the forms, reports and queries are on the
Queries, forms and reports page. The namespace is
urn:oasis:names:tc:opendocument:xmlns:database:1.0, written db: below. Types are the schema’s:
boolean is true or false, string is text, positive integer is a whole
number from 0 up.
Data source
db:data-source has no attributes. It holds db:connection-data (required),
db:driver-settings and db:application-connection-settings (both optional).
Connection data
db:connection-data holds either a db:database-description or a
db:connection-resource, then an optional db:login.
| Element | Attribute | Value |
|---|---|---|
db:connection-resource | xlink:type | Required, simple. |
xlink:href | Required. The address of the data source: sdbc:embedded:hsqldb and sdbc:embedded:firebird for a database inside the package, otherwise a connection address such as sdbc:mysql:jdbc:host:3306/name. | |
xlink:show | Optional, none. | |
xlink:actuate | Optional, onRequest. | |
db:database-description | (none) | Holds one of db:file-based-database or db:server-database. |
db:file-based-database | xlink:type | Required, simple. |
xlink:href | Required. The database file’s address. | |
db:media-type | Required string: the media type of that file. | |
db:extension | Optional string: the file name extension. | |
db:server-database | db:type | Required, a namespaced token naming the kind of server. |
db:hostname | Required with a host and port, a string. | |
db:port | Optional positive integer, with the host. | |
db:local-socket | Optional string, used instead of the host and port. | |
db:database-name | Optional string. | |
db:login | db:user-name | Optional string; the schema lets either this or db:use-system-user appear, not both. |
db:use-system-user | Optional boolean: log in as the operating system user. | |
db:is-password-required | Optional boolean. | |
db:login-timeout | Optional positive integer. |
Driver settings
db:driver-settings may hold db:auto-increment, db:delimiter,
db:character-set and db:table-settings, each at most once.
| Element | Attribute | Value |
|---|---|---|
db:driver-settings | db:show-deleted | Optional boolean: show deleted rows (a dBASE table’s). |
db:system-driver-settings | Optional string. | |
db:base-dn | Optional string: the base distinguished name for an LDAP address book. | |
db:is-first-row-header-line | Optional boolean: the first row of a text file holds the column names. | |
db:parameter-name-substitution | Optional boolean. | |
db:auto-increment | db:additional-column-statement | Optional string: the SQL added to a column definition to make it auto-incrementing. |
db:row-retrieving-statement | Optional string: the SQL that returns the value just generated. | |
db:character-set | db:encoding | Optional, a text encoding name. |
db:delimiter | db:field | Optional string: the field separator of a text file. |
db:string | Optional string: the text delimiter. | |
db:decimal | Optional string: the decimal separator. | |
db:thousand | Optional string: the thousands separator. | |
db:table-settings | (none) | Holds any number of db:table-setting. |
db:table-setting | db:is-first-row-header-line | Optional boolean. May hold a db:delimiter and a db:character-set, which apply to that table. |
db:show-deleted | Optional boolean. |
Application connection settings
db:application-connection-settings holds, each optional, db:table-filter,
db:table-type-filter and db:data-source-settings.
| Element | Attribute | Value |
|---|---|---|
db:application-connection-settings | db:is-table-name-length-limited | Optional boolean. |
db:enable-sql92-check | Optional boolean. | |
db:append-table-alias-name | Optional boolean: write AS before a table alias. | |
db:ignore-driver-privileges | Optional boolean. | |
db:boolean-comparison-mode | Optional: equal-integer, is-boolean, equal-boolean or equal-use-only-zero. | |
db:use-catalog | Optional boolean. | |
db:max-row-count | Optional integer: how many rows a table or query shows at most. | |
db:suppress-version-columns | Optional boolean. | |
db:table-filter | (none) | Holds an optional db:table-include-filter and an optional db:table-exclude-filter, each with one or more db:table-filter-pattern (text: a table name pattern where % stands for any characters). |
db:table-type-filter | (none) | Holds any number of db:table-type (text: for example TABLE or VIEW). |
db:data-source-settings | (none) | Holds one or more db:data-source-setting. |
db:data-source-setting | db:data-source-setting-name | Required string. |
db:data-source-setting-type | Required: boolean, short, int, long, double or string. | |
db:data-source-setting-is-list | Optional boolean: the setting is a list of values. | |
db:data-source-setting-value | (none) | One or more per setting, text. |
Table representations
db:table-representations holds any number of db:table-representation, which say how the program
shows one table. Each may hold db:order-statement, db:filter-statement and
db:columns, in that order.
| Element | Attribute | Value |
|---|---|---|
db:table-representation | db:name | Required string: the table’s name. |
db:catalog-name | Optional string. | |
db:schema-name | Optional string. | |
db:title | Optional string. | |
db:description | Optional string. | |
db:style-name | Optional: a table-column style of the document’s styles (the style the table’s columns use). | |
db:default-row-style-name | Optional: a table-row style. | |
db:order-statement and db:filter-statement | db:command | Required string: the SQL ORDER BY or WHERE expression. |
db:apply-command | Optional boolean: whether it is applied when the table is opened. | |
db:columns | (none) | One or more db:column. |
db:column | db:name | Required string. |
db:title, db:description | Optional strings. | |
db:visible | Optional boolean: whether the column shows. | |
db:style-name | Optional: a table-column style (its width). | |
db:default-cell-style-name | Optional: a table-cell style. | |
office:value-type, office:value, office:string-value, office:boolean-value, office:date-value, office:time-value, office:currency, calcext:value-type | The column’s default value, with the same meaning as on a spreadsheet cell (calcext: is LibreOffice’s extension). |
Schema definition
db:schema-definition holds db:table-definitions, which holds any number of
db:table-definition: the structure of a database written out in the document (as opposed to read from
the database when it is opened).
| Element | Attribute | Value |
|---|---|---|
db:table-definition | db:name, db:catalog-name, db:schema-name | The table’s name (required) and optional catalog and schema. |
db:type | Optional string: the table type (TABLE, VIEW …). | |
Holds db:column-definitions (required), then optional db:keys and db:indices. | ||
db:column-definitions | (none) | One or more db:column-definition. |
db:column-definition | db:name | Required string. |
db:data-type | Optional: bit, boolean, tinyint, smallint, integer, bigint, float, real, double, numeric, decimal, char, varchar, longvarchar, date, time, timestmp, binary, varbinary, longvarbinary, sqlnull, other, object, distinct, struct, array, blob, clob or ref. | |
db:type-name | Optional string: the database’s own name of the type. | |
db:precision, db:scale | Optional positive integers. | |
db:is-nullable | Optional: no-nulls or nullable. | |
db:is-empty-allowed | Optional boolean. | |
db:is-autoincrement | Optional boolean. | |
office:value-type, office:value and the other value attributes of a column | The default value, as on a table column. | |
db:keys | (none) | One or more db:key. |
db:key | db:type | Required: primary, unique or foreign. |
db:name | Optional string. | |
db:referenced-table-name | Optional string: for a foreign key, the table it points to. | |
db:update-rule, db:delete-rule | Optional: cascade, restrict, set-null, no-action or set-default. | |
Holds one or more db:key-columns, each with one or more db:key-column. | ||
db:key-column | db:name | Optional string: the column in this table. |
db:related-column-name | Optional string: for a foreign key, the column it points to. | |
db:indices | (none) | One or more db:index. |
db:index | db:name | Required string. |
db:catalog-name | Optional string. | |
db:is-unique, db:is-clustered | Optional booleans. | |
Holds one or more db:index-columns, each with one or more db:index-column. | ||
db:index-column | db:name | Required string. |
db:is-ascending | Optional boolean. | |
Reading it
The explorer lists the connection, login and settings under Data source, the filter patterns and free-form settings in their own tables, and every table representation column. A name that the schema does not give an element (some programs add their own) shows in the Names tab as not defined, or as a LibreOffice extension when it is in LibreOffice’s own schema.
Not described
This page follows the OpenDocument 1.3 RELAX NG schema (read in full for the db: elements) and
LibreOffice’s test documents; it does not repeat the specification’s prose.
Known, not yet covered
- Reference: which connection addresses (
sdbc:…) LibreOffice accepts and what each driver does withdb:system-driver-settings,db:base-dnand the free-formdb:data-source-settingnames; they belong to LibreOffice’s drivers, not to OpenDocument. - Reference: the values of
db:typeondb:server-database(a namespaced token: the schema names no list).
Unknown
- Reference: how a reader treats
db:schema-definition: no sample read writes one.