Each table is described by a table definition on one or more TDEF pages (type
02). This page follows MDB Tools’ HACKING.md; offsets are
hexadecimal and numbers little-endian. Pages and rows are on
header, pages and rows.
TDEF page header
| Offset | Size | Field |
|---|---|---|
00 | 1 | Page type 02. |
01 | 1 | Unknown, 01. |
02 | 2 | Jet 3: VC. Jet 4: free space − 8. |
04 | 4 | Next TDEF page of this table, or 0. |
A long definition continues on the next page after its 8-byte header. The table block below starts at offset 8.
Table block
| Jet 3 | Jet 4 | Size | Field |
|---|---|---|---|
00 | 00 | 4 | Length of the definition. |
| – | 04 | 4 | Jet 4: a tag, 1625. |
04 | 08 | 4 | Number of rows. |
08 | 0C | 4 | Next autonumber value. |
| – | 10 | 1 | Jet 4: 01 when autonumbering is on. |
| – | 11 | 3 | Jet 4: unknown, zero. |
| – | 14 | 4 | Jet 4: autonumber for complex columns. |
| – | 18 | 8 | Jet 4: unknown; uninitialised leftovers. |
0C | 20 | 1 | Table type: 4E (N) user table, 53 (S) system table. |
0D | 21 | 2 | Maximum number of columns a row will have (max_cols); deletions do not decrement it. |
0F | 23 | 2 | Number of variable-length column slots; a deleted column keeps its slot, so this can be more than the variable columns the table now has. |
11 | 25 | 2 | Number of columns. |
13 | 27 | 4 | Number of logical indexes. |
17 | 2B | 4 | Number of physical indexes. |
1B | 2F | 4 | Pointer to the usage map of used pages. |
1F | 33 | 4 | Pointer to the usage map of free pages. |
Then, in order: index statistics (8 bytes per physical index in Jet 3, 12 in Jet 4);
the column definitions; the column names (Jet 3: 1-byte length
and the name; Jet 4: 2-byte length and UCS-2); the
physical index blocks; the logical index blocks; the index
names; and a list of usage-map entries (column number, used pages, free pages) ended
by column number FFFF.
Column definitions
| Jet 3 | Jet 4 | Size | Field |
|---|---|---|---|
00 | 00 | 1 | Column type. |
| – | 01 | 4 | Jet 4: tag, 1625. |
01 | 05 | 2 | Column number. |
03 | 07 | 2 | Position in the variable offset table (offset_V); a deleted column leaves its position. |
05 | 09 | 2 | Column ID, given when the column was created and never renumbered, so a table that lost a column has gaps here while the column number shifts. |
07 | – | 2 | Jet 3: file_flag, a copy of the byte at 38 of the database definition page (0 or 1, the same on every column of the file); what it records is unknown. |
09 | – | 2 | Jet 3: sort order of text columns (0409 General). |
0B | 0B | 2 | Jet 3: precision and scale (one byte each), or the code page for text (04E4 is CP1252). Jet 4: precision and scale, or the sort order for text columns (0409 General), or for complex columns a 4-byte complex id. |
| – | 0D | 2 | Jet 4: misc_ext: the collation variant in the first byte, the text sort order version in the second. Together with the sort order they make the Access 32-bit sort id: LCID, variant, weight table family. |
0D | 0F | 1 | Column flags. |
| – | 10 | 1 | Jet 4: extended flags (misc_flags). |
| – | 11 | 4 | Jet 4: unknown, zero. |
0E | 15 | 2 | Offset of a fixed-length column in the row. |
10 | 17 | 2 | Column length. |
A column definition is 18 bytes in Jet 3 and 25 in Jet 4.
Column types
| Code | Type | Stored as |
|---|---|---|
01 | Boolean | A bit in the null mask |
02 | Byte | 8 bits |
03 | Integer | 16 bits |
04 | Long integer | 32 bits |
05 | Currency | 64 bits (the notes give no scale) |
06 | Single | 32-bit float |
07 | Double | 64-bit float |
08 | Date/time | 64-bit double: days since 30 December 1899, with the time as a positive fraction of the day whatever the sign of the double. A date before the epoch has a negative whole-day part and a positive time, and a value whose whole-day part is zero reads the same for either sign, so the sign of such a value cannot be recovered. Access records seconds, but a file can hold a double with far more precision (one seen is −0x1.70681cf4d859ap−12, 30.355776 seconds into 1899-12-30; some resolve finer than a nanosecond). |
09 | Binary | Up to 255 bytes |
0A | Text | Up to 255 characters |
0B | OLE object | Long binary, memo header |
0C | Memo | Long text, memo header |
0D, 0E | – | Not column types; both engines reject them |
0F | Replication ID | 16-byte GUID |
10 | Numeric | 17 bytes, a scaled decimal |
11 | Big binary | Fixed binary, declared length 4,000, longer than the 255-byte binary. The only use seen is the Data column of MSysAccessObjects, which holds the forms, reports and VBA as a chunked OLE compound file. Jet 4 only (Jet 3 used Binary; the ACE engine dropped the table, so an .accdb has none). |
12 | Complex | 32-bit key of a complex column: multi-valued fields, version history and attachments (ACE) |
13 | Big integer | 64 bits (ACE; arrived in Access 2016 at build 16.0.7812, so an earlier ACE engine rejects it) |
14 | Extended date/time | 42 bytes of ASCII (Access 2019): 19 digits of days since 0001-01-01, a colon, 12 digits of seconds, 7 digits of 100-nanosecond units, then :7 and a null byte. Keeps a date from year 1 with 7 digits of fractional seconds. |
Column flags
| Bit | Meaning |
|---|---|
01 | Fixed-length column |
02 | Can be updated |
04 | Autonumber (long) |
08 | Not seen set on any column examined |
10 | Access maintains the column and hides it: the columns of the system catalog tables (MSysComplexColumns included) and the replication columns (“s_” and “Gen_”) |
20 | Holds a Windows security identifier; only MSysObjects.Owner and MSysACEs.SID carry it |
40 | Autonumber (GUID) |
80 | Hyperlink. Syntax Link Title#http://example.com/somepage.html# or #PAGE.HTM# |
In Access 2007 and 2010, complex columns (multivalued fields, version history, attachments)
always have the flag byte exactly 07. The Jet 4 misc_flags byte, which the
Jet 3 column block has no room for:
| Bit | Meaning |
|---|---|
01 | The text of the column is stored in the compressed Unicode form |
02 | Column added to make the database replicable: the row-tracking columns s_GUID, s_Lineage, s_Generation, s_ColLineage, and Gen_<column> or Aen_<column>, which tracks one column for conflict resolution; the types vary with the tracked column |
08 | The complex-value foreign key of a complex column’s flat table; Access refuses to open a table whose flat table lacks it |
10 | A value column of an attachment flat table: FileData, FileFlags, FileName, FileType, FileTimeStamp, FileURL. Access writes it and does not require it |
20 | A version history complex column. Access requires it; without it the datasheet shows that column as a column of its own |
C0 | The column is calculated. The expression is the column’s Expression property; each row stores the last computed value inside a 23-byte wrapper whose bytes 16 to 19 give the value’s length, the value following. A calculated column of fixed type declares a length of 39 |
Attachment data has an 8-byte wrapper (a 4-byte flag saying whether the content is deflated and a
4-byte length), then the content, which starts with its own header: a 32-bit header length
(including itself), a 32-bit constant 1, a 32-bit character count of the string that follows, and
the file extension in UCS-2 with a null terminator. Access stores jpg jpeg gif png zip cab docx xlsx xlsb pptx
raw and deflates everything else, archives and mp3 files included.
Indexes
Physical index (Jet 3: 39 bytes; Jet 4: 52 bytes): Jet 4 starts with a 4-byte tag (1923); then 10 entries of a 2-byte column number and a 1-byte order; the used-pages map pointer (4); the first index page (4); Jet 4 adds 4 unknown bytes; the index flags (1); Jet 4 adds a complex-index byte and 4 zero bytes.
Logical index (Jet 3: 20 bytes; Jet 4: 28): Jet 4 starts with a
4-byte tag (1625); then the index number (4), the physical index number (4), the
related table’s type (1), the related index number (4, FFFFFFFF when not a
foreign key), the related table’s page (4), cascade updates (1), cascade deletes (1)
and the index type (1: 01 primary key, 02 foreign key); Jet 4
ends with 4 zero bytes.
| Index flag | Meaning |
|---|---|
01 | Unique |
02 | Ignore nulls |
08 | Required |
80 | Set by Access 2000 and later on every index it writes; meaning unknown |
Bits 04, 10, 20 and 40 have not been seen set on
any index. The column order byte of an index column has been seen only as 01 for
ascending and 00 for descending; column number FFFF means no column. There
are at most 10 columns per index.
Physical and logical indexes. The physical index info (num_real_idx) and
the logical index info (num_idx) normally correspond one to one, but there can be more
logical than physical ones (only seen for foreign keys): several logical indexes share one physical
index, and index_num2 says which physical index backs which logical one. When Access
creates a relationship with “enforce referential integrity”, each table gets an extra logical index of
type 2 (foreign key) holding a pointer to the related table (rel_tbl_page) and its logical
index (rel_idx_num); rel_tbl_type says which table is the primary one, from
which cascaded updates and deletes flow. If the foreign key columns are already indexed by another
logical index (for instance one the user made), the foreign key index shares that physical index.
cascade_dels is 01 to cascade deletes and 02 to set the foreign
key to null on delete. index_num is not always in sequence. The index statistics per
physical index are two row-count figures (the second “kept loosely”) and, in Jet 4, four more bytes,
zero in every block seen. Index names follow the logical index blocks (1-byte length in Jet 3,
2 bytes and UCS-2 in Jet 4), then the loop of column number, used-pages pointer and free-pages
pointer ends at column number FFFF.
Index pages
MDB Tools says indexes are not completely understood. The root of an index (in the index
definition) may be an intermediate page (type 03), a leaf page (type 04) if
there is a single index page, or, for a table small enough to fit on one page, a data page (type
01).
| Offset | Size | Field (Jet 3) |
|---|---|---|
00 | 1 | Page type: 03 intermediate, 04 leaf. |
01 | 1 | Unknown, 01. |
02 | 2 | Free space at the end of the page. |
04 | 4 | Page number of the index’s table definition (parent_page). |
08 | 4 | Previous page at this index level. |
0C | 4 | Next page at this index level. |
10 | 4 | Pointer to the tail leaf page. |
14 | 1 | pref_len: length of the shared entry prefix. |
15 | 1 | Level: depth of the page above the leaves; 0 on a leaf, one more than its children on a node page. |
Jet 4 adds a 4-byte write stamp after parent_page (the field a data page carries) and widens
pref_len to 2 bytes, which puts the level at offset 1A. (Over 5,904 Jet 3 index
pages the level was 0 on all 5,683 leaves, 1 on 212 node pages and 2 on 9 more, so reading
pref_len as 2 bytes on Jet 3 gives 256 or 512 on every node page.) The offsets above
follow from the field sizes in HACKING.md; it states them as a sequence, not as offsets.
Both kinds of index page have a bitmask starting at 16 (Jet 3) or 1B (Jet 4)
that marks where each index entry starts, counting from the low bit of each byte. The first entry begins
at F8 (Jet 3) or 1E0 (Jet 4) and is not marked. Example: bytes
00 20 00 04 80 00 mark entries at 13 (0D), 26 (1A) and 39
(27) bytes from the first; the last is the stopping point, not an entry. The mask covers
the page: (F8 − 16) × 8 = 710 against 800 −
F8 = 708 in Jet 3, and (1E0 − 1B) × 8 =
E28 against 1000 − 1E0 = E20 in Jet 4.
| Index record | Size | Meaning |
|---|---|---|
flags | 1 | 7F (MSB) or 80 (LSB, the one’s complement, used for descending order, all bytes negated), 00 (or FF descending) when the key column is null and no data follows, only the page pointer. Repeated with its data for each column of a multi-column key. |
| indexed columns | variable | The key column data. |
| data page | 3 | Page containing the row the entry refers to. |
| data row | 1 | Row number on that page. |
| child page | 4 | Intermediate pages only: the next-level page (possibly a leaf) of which this is the last entry. |
Leaf entries have the key columns and the 3-byte page and 1-byte row number only. Entries sort by the
lexicographic order of the whole entry’s bytes, so descending order is the byte negation, and the flag
puts nulls first (ascending) or last (descending). Shared prefix: if
pref_len is above 0, the first pref_len bytes of the first entry are prepended
to every later entry. Example: with prefix length 4, the first entry (key 1, page 261 = 00 01 05,
row 3) is 7F 00 00 00 01 00 01 05 03; the next entry 02 00 01 05 04 is really
[7F 00 00 00] 02 00 01 05 04, key 2, page 261, row 4. Because text is mangled by the key
encoding, covered queries (answered from the index alone) are not possible on text columns.
The tail leaf page: when new leaf pages are added at the end of an index (a primary key usually),
the last leaf’s tail pointer points to the new leaf without updating the tree above, since entries in
intermediate pages point to the last entry of a page; the tail page is updated alone until full and
then moved into the index proper.
Key encoding
- An index entry is limited to 255 characters of key: 255 bytes in Jet 3, 510 in Jet 4. A longer
key keeps all but the last 2 bytes of that and ends with a 2-byte digest of the discarded bytes, a
CRC-16/ARC (polynomial
8005) with the register held in on-disk byte order. Every discarded byte feeds it but the last is XORed into the register instead of clocked through it, whatever it is (a text terminator, a weight an odd nibble left behind, or the low byte of a number in the last column). - A text column is indexed up to 255 characters, memo columns included, with trailing spaces dropped before encoding.
- Text keys use an “alphabetic sort order” form:
0–9become56–5F;A–Zanda–zboth become60–79. A text column ends with00(FFif negated). This is the General sort order of Access 2000 to 2007 (1033, version 0); since Access 2010 it is called “General legacy” and the 2010 “General” is a new encoding (1033, version 1). - A collation is named by the whole 32-bit sort id, not the LCID; the list Access offers is a list of
collations (Russian cannot be chosen, German only as Phone Book, Danish only as Norwegian/Danish).
58 LCIDs resolve to 1033 and need no tailoring. Other locales have a tailoring: a few characters take
a different weight, every case together; Turkish gives capital I the weights of dotless ı and İ those
of i; some collations weigh a sequence as a unit (Czech
ch); a few characters are weighed as two, three or four; repeat marks and prolonged sound marks copy or lengthen the previous weight; French orders the diacritics from the end. MDB Tools describes these cases with worked entries; the weight tables themselves and the full rules are not reproduced here (see “Not described”).
The catalog
MSysObjects names every object. Id is the page number of the object’s TDEF page
for a table, ParentId groups rows under the system objects Tables,
Databases and Relationships, and Name is unique within a parent.
Type: 1 table, 4 linked ODBC table, 5 query, 6 linked table. A linked table has no TDEF
page; Database and ForeignName name the file and table it stands for, and a
linked ODBC table carries a Connect string instead. Flags marks a system object
with 80000000 or 00000002, and a hidden object with 08. Catalog
entries are also what MDB Tools calls “system tables”: tables whose names start with
MSys.
Complex columns
A complex column (multivalued field, attachment, version history) is a LONG autonumber whose value is the
key of the rows holding the data; the column type is 12 and its 4-byte misc field holds a
complex id. They exist only in the Access 2007 format and later.
MSysComplexColumns maps the complex id to the supporting tables:
ConceptualTableID (TDEF page of the table declaring the column), ColumnName,
FlatTableID (the table holding the values) and ComplexTypeObjectID (a type table).
The type table’s name says the kind: MSysComplexType_Attachment an attachment,
MSysComplexType_<other> a multivalued field, MSysComplexTypeVH_<guid> a
version history. The first two kinds are shared, one per database, and Access creates them whether or not
a column uses them; a version history type table is created per column (hence the guid) and holds a memo
column named after the memo column whose versions it keeps, and a date column, in either order.
A version history column in the declaring table is always named
VersionHistory_F5F8918F-0A3F-4DA9-AE71-184EE5012880 and the date column of its type table
Modified_F9B5E312-4155-4c59-9AAE-391C1B295827; only the type table’s own guid varies per
column, so a table can keep the version history of at most one memo column. The flat table is named
f_<32 hex digits>_<column>, cut to the 64 characters a table name may have. Its
indexes: MSysComplexPKIndex on the primary key, _<column> on the foreign key,
and for a multivalued field or attachment IdxFKPrimaryScalar on the foreign key plus a value
column (Value or FileName). Access also writes a unique
<column>_<32 hex digits> index on the complex column itself, cut to 64 characters.
Only the foreign key index is needed to read the values. Each flat-table row carries the complex id of the
row it belongs to in a foreign key column (extended flag 08) and a LONG autonumber primary key,
the id of one value, plus the type table’s columns by the same names. The complex id is a per-row
autonumber of the declaring table and is shared by every complex column of the row; a row written before the
column was added holds none (Access shows and edits it but fails to save the edit).
MSysObjects.Flags tells the part an object plays: 00040000 on the declaring table
(without it Access never looks for the values), 000A0000 on the flat table (without it Access will
not open it), 00030000 on a type table; Access also sets 80000000 on both supporting
kinds, which only hides them from the navigation pane. Access reads a multivalued field’s row source from the
RowSourceType and RowSource properties of the flat table’s value column and offers no
way to add a value unless the row source names at least one. An attachment column carries no properties, nor
does a version history column, but the memo column it shadows (and the table) carry
AppendOnly.
Properties
Design View properties (defaults, description, format, required and so on) are stored in the
LvProp column of MSysObjects as OLE fields. They start with a 32-bit header:
KKD and a zero byte in Jet 3, MR2 and a zero byte in Jet 4. Then chunks, each
with a 32-bit length (including itself) and a 16-bit type: 0080 holds the names shared by the
other chunks, as repeated 16-bit name length and name (0D 00 and
AccessVersion); the others hold values for an object: 0000 the object itself (the
table, usually unnamed), 0001 a named column of it, 0002 a named index of it.
A value chunk starts with a 32-bit length (including itself), a 16-bit name length and the name
(column name or index name), followed by one or more data records:
| Size | Field |
|---|---|
| 2 | Length (including itself). |
| 1 | Flags (below). |
| 1 | Type. |
| 2 | Name: an index into the names of the 0080 chunk. |
| 2 | Value length, not including itself. |
| n | The value (for example 07.53 for the AccessVersion example). |
The flag byte is a bit field. Bit 01 is the DDL argument of the DAO CreateProperty method (a
user cannot change or delete a DDL property without dbSecWriteDef permission); bit 80 tells
Access to store the value without running the handler the property name is bound to, so writing the property
records a state instead of bringing it about (Access sets it itself, for example when a replication conversion
stamps Replicable on each table afterwards; no DAO call produces it). The whole byte must be
written back unchanged. The value types of the Type byte are not listed in MDB Tools’
notes (see its props.c).
Name maps
A name map is the data behind Access’s Name AutoCorrect option: it records the tables and columns an object
depends on and ties each to the guid in the GUID property of that table or column, so renames can
be repaired. Only Jet 4 and later files have them, stored as OLE properties in the default property block of the
object’s MSysObjects row: a table has a NameMap property (a table record for itself,
a column record per column and a reference record per name used by an expression in the table), a query has a
DOL property in the same format (a table record for each table or query it reads and a column
record for each column it uses; a union, pass-through or data definition query has the magic value alone), and a
linked table has one too. The database properties Track Name AutoCorrect Info and
Perform Name AutoCorrect (LONG) switch the option; if missing, Access takes it as on.
NameMap := u32 magic 0x550ECC0A [u32 reserved, record*]
record := guid[16], u32 type, payload[16], name, u32 zero
The name is little-endian UCS-2 with a null terminator whatever the database’s charset; the trailing zero is left off the last record; there is no record count, so a reader stops at the end of the data.
| Type | Record | Payload |
|---|---|---|
| 0 | table | 8-byte date, then 8 bytes of writer state |
| 6 | reference | guid of the table |
| 7 | column | guid of the table |
| 12 | end | tag of the Access build that wrote the map; older builds did not write this record |
The guid of a reference or end record is zero. The date in a table record is the table’s
DateUpdate in MSysObjects when the name map was written. Access rewrites a table’s
name map when a design save changes a column or index, but not for a table property change, a rename in the
Navigation Pane, data entry or a compact. A renamed column keeps its guid; a table renamed in the pane keeps its
old name in its table record until the next design save. Access repairs a query when it next opens it, finding
each DOL record by guid and changing the SQL and the DOL if the name differs; a query
table record for a source query carries that query’s guid and its column records the guids of the columns the
source reads. A query’s name map must not be changed without its SQL. Name maps often disagree with their
tables even in files only Access wrote, so finding a column record by name is more reliable than by guid.