The DBF format was never standardised, and each dBASE and FoxPro version extended it. Sources for this page: Microsoft’s Table File Structure and Memo File Structure (.FPT) pages for Visual FoxPro, and Erik Bachmann’s Xbase format notes for dBASE (DBF, data types, DBT). Numbers are little-endian unless noted.
Header
| Offset | Size | Description |
|---|---|---|
0 | 1 | Version byte: see versions. |
1 | 3 | Date of last update: year − 1900, month, day (YYMMDD, one byte each; the header date has no century, the Xbase notes give the range 00 to FF, so 1900 to 2155; dates in records are YYYYMMDD). |
4 | 4 | Number of records. |
8 | 2 | Header length: where the first record starts. |
10 | 2 | Record length, including the deletion flag. |
12 | 16 | Reserved in Visual FoxPro. dBASE IV: bytes 12–13 reserved; byte 14 incomplete transaction (01 started, 00 ended or rolled back); byte 15 encryption (01 encrypted); bytes 16–19 free record thread (LAN); bytes 20–27 reserved for multi-user dBASE. |
28 | 1 | Table flags. Visual FoxPro: 01 has a structural .cdx index, 02 has a memo field, 04 is a database container (.dbc); they add up. dBASE IV (MDX flag): 01 a production .mdx file is present, 00 none (index on demand). FoxBase (Xbase notes): 01 a compound .cdx is present, 00 none. The Xbase notes also list 07 for Visual FoxPro as a database container including memo and indexes (the sum of the three flags). |
29 | 1 | Code page mark (language driver ID); see the table below. |
30 | 2 | Reserved, 0. |
32 | 32 each | Field descriptors. |
| … | 1 | Terminator 0D. |
| … | 263 | Visual FoxPro only: the backlink, the relative path of the database container the table belongs to, or zeros. |
Microsoft’s page says the records start at the position in bytes 8–9, so a reader should use that rather than the terminator’s position (Visual FoxPro’s backlink sits in between).
Code page marks (byte 29)
The Xbase notes list these for FoxPro; the values follow DOS and Windows code pages. Microsoft’s table page only calls the byte “code page mark” and points to a separate list of code pages for Visual FoxPro, which was not read.
| Value | Meaning | Value | Meaning |
|---|---|---|---|
01 | DOS USA, code page 437 | 6A | Greek MS-DOS (437G) |
02 | DOS multilingual, code page 850 | 6B | Turkish MS-DOS |
03 | Windows ANSI, code page 1252 | 96 | Russian Macintosh |
04 | Standard Macintosh | 97 | Eastern European Macintosh |
64 | Eastern European MS-DOS, code page 852 | 98 | Greek Macintosh |
65 | Nordic MS-DOS, code page 865 | C8 | Windows EE, code page 1250 |
66 | Russian MS-DOS, code page 866 | C9 | Russian Windows |
67 | Icelandic MS-DOS | CA | Turkish Windows |
68 | Kamenicky (Czech) MS-DOS | CB | Greek Windows |
69 | Mazovia (Polish) MS-DOS |
dBASE 7’s language driver names and the full dBASE language driver list are not in these sources.
Version byte
The two sources list different values. The Xbase notes list:
| Value | Meaning |
|---|---|
02 | FoxBase |
03 | File without a DBT memo (dBASE III and most writers; shapefiles use it) |
04 | dBASE IV without memo |
05 | dBASE V without memo |
07 | Visual Objects without memo |
30 | Visual FoxPro |
31 | Visual FoxPro with autoincrement |
43 | .dbv variable-size memo (FlagShip) |
7B | dBASE IV with memo |
83 | File with a DBT memo (dBASE III) |
87 | Visual Objects with memo |
8B | dBASE IV with memo |
8E | dBASE IV with SQL table |
B3 | .dbv and .dbt memo (FlagShip) |
E5 | Clipper SIX driver with SMT memo |
F5 | FoxPro with memo |
FB | FoxPro (meaning unclear in the notes) |
Microsoft’s Visual FoxPro page gives 01, 02 FoxBASE,
2F FoxBASE+/dBASE III PLUS without memo, 30 Visual FoxPro,
31 with autoincrement, 42 with Varchar, Varbinary or Blob,
62 and 82 dBASE IV SQL table and system files without memo,
8A FoxBASE+/dBASE III PLUS with memo, CA dBASE IV with memo,
F4 dBASE IV SQL table with memo and FA FoxPro 2.x with memo.
Several differ from the Xbase notes’ values for the same product (for example Microsoft
gives 2F for FoxBASE+/dBASE III PLUS without memo, the notes 03;
8A, CA and F4 against 83/8B
and F5). Which is right for each writer is not settled by the sources.
The Xbase notes also describe the dBASE IV version byte as bit flags MSSSFVVV:
bits 0 to 2 the version number, bit 3 a memo file, bits 4 to 6 an SQL table, bit 7 the
dBASE III memo (DBT) flag. For encrypted databases the Clipper SIX driver sets the
lowest three bits to 110 (3 becomes 6, 83 becomes
86, F5 becomes F6, E5 becomes
E6), and the notes list 30 twice, for Visual FoxPro and Visual
FoxPro with a database container.
dBASE 7 uses a different table layout that neither source describes.
Field descriptors
| Offset | Size | Description |
|---|---|---|
0 | 11 | Field name, up to 10 characters, padded with NUL. |
11 | 1 | Field type, a letter. |
12 | 4 | Visual FoxPro: displacement of the field in the record (Microsoft: bytes 12 to 15; the Xbase notes: bytes 12 to 13). dBASE: an address in memory, of no use in files. |
16 | 1 | Field length in bytes, 0 to 255 (the notes give a maximum of 255). For non-numeric fields in FoxPro and Clipper, byte 17 is the high byte of the length (256 to 65,535). |
17 | 1 | Decimal places (for Numeric, at most 15 per the notes), or the high byte of the length as above. |
18 | 1 | Visual FoxPro field flags: 01 system column, hidden; 02 can be null; 04 binary (Character and Memo); 06 null and binary; 0C autoincrement. dBASE: bytes 18–19 reserved for multi-user dBASE. |
19 | 4 | Visual FoxPro: next autoincrement value. dBASE: byte 19 reserved, byte 20 work area ID, bytes 21–22 reserved. |
23 | 1 | Visual FoxPro: autoincrement step. dBASE: SET FIELDS flag. |
24 | 8 | Reserved. dBASE IV: byte 31 is the index field flag, 01 when the field has a key in the production .mdx index and 00 when not. |
The notes say the work area ID (byte 20) is 01 in all dBASE III files, and
that a table has at most 128 fields. An empty memo field’s reference is 10 blanks.
Microsoft gives the number of fields in a Visual FoxPro table as
(x − 296) / 32 where x is the position of the first record (296 =
263 backlink + 1 terminator + 32 for the first field); its page prints the formula as
“(x – 296/32)”. If the first backlink byte is 00 the table is not
associated with a database, and a database file always has 00.
Field types
| Type | Name | Stored as |
|---|---|---|
C | Character | ASCII text, under 254 bytes in dBASE; up to 32 KB in Clipper and FoxPro using the decimal count as the high byte of the length, and up to 64 KB when the length is read as unsigned. The notes say only fields of 100 characters or fewer can be indexed. An unnamed variable-length character type of 1 to 254 characters is also noted (64 KB in FoxBase and Clipper). |
N | Numeric | A number as ASCII digits, - and the decimal point; under 18 digits (20 in FoxPro and Clipper). |
F | Float | 20 digits as text (dBASE IV and later, FoxPro, Clipper). |
L | Logical | One byte: T, t, Y, y, F, f, N, n or ? (not initialised, the default). Always displayed as T, F or ?. Some sources say a space is valid for not initialised; it may occur but is not defined. |
D | Date | 8 characters, YYYYMMDD. A date such as 0000-00-00 is not valid. |
M | Memo | 10 digits: the block number in the memo file; blanks when empty. |
G | General | OLE object, stored like a memo (dBASE V for Windows, FoxPro). |
P | Picture | FoxPro: picture, stored like a memo. |
B | Binary / double | dBASE V: binary data stored like a memo. Visual FoxPro: double. |
Y | Currency | Visual FoxPro. The sources give no byte layout. |
T | DateTime | Two 32-bit little-endian numbers: the Julian day (15 October 1582 = 2,299,161), then milliseconds since midnight. |
I | Integer | 4-byte little-endian integer. |
V | Varchar | Visual FoxPro: when its “varlength” bit is set in the hidden null-flags field, the real length is in the field’s last byte. FlagShip uses V differently (a 10-byte pointer into a .dbv file). The Xbase notes describe a “VariField” of 2 to 10 bytes: a weakly-typed one stores part of the character data in the field and the rest in the memo file, with a 6-byte pointer at the end of the field entry (so the field width must allow for it); a strongly-typed one stores DATE values in 3 bytes and long integers in 4 bytes, and a field defined with 4 bytes is taken as strongly typed (the rest of that passage was not read). |
Q | Varbinary | Visual FoxPro: as Varchar, binary. |
W | Blob | Visual FoxPro. |
@ | Timestamp | Two 32-bit numbers: days since 1 January 4713 BC, then milliseconds. |
O | Double | 8 bytes. |
+ | Autoincrement | A long integer. |
2, 4, 8 | FlagShip binary | Short (2), long (4) and double (8) binary numbers. |
Records
Each record starts with a deletion flag, 20 (space) for a live record
and 2A (*) for a deleted one, then the fields in order with
no separators; the record length is the sum of the field lengths plus the flag byte.
The file ends with 1A, the end-of-file mark the Xbase notes give; a
reader should rely on the record count rather than on this byte. The notes say dBASE II
treats any 1A as the end of the file, while dBASE III treats it as an
ordinary character and appends an extra one at the physical end; a packed file can be
physically larger than its logical size, with garbage after the mark. They also report
that new records are appended, not inserted, and that a deleted record disappears only
by PACK. The header is binary and little-endian (unsigned); record data is
ASCII. In dBASE II to dBASE 5 and Xbase this layout applies; dBASE 7 has a different
one (not described by these sources).
Memo files
.dbt, dBASE III (Xbase notes): a 512-byte header — bytes 0–3 the next free block, 4–15 reserved, byte 16 the version03— then 512-byte blocks from block 1 (the rest of the header is garbage). A memo runs over consecutive blocks and ends with two1Abytes; the rest of the block is unused (one terminator is reported for FoxPro). The next available block always points at the end of the file, and data is only appended: every rewrite of a memo field appends again, although dBASE V for DOS may reuse the space if the new memo fits the allocated blocks. Deleted data is not marked; valid memos can only be found from the data file, and the memo file itself does not say what it holds (binary data in B and G fields must not be treated as text)..dbt, dBASE IV (Xbase notes): header bytes 0–3 next free block, 8–15 the DBF name without extension, 20–21 the block length (set bySET BLOCKSIZE, default 512). Each memo block starts withFF FF 08 00and a 4-byte length; the notes do not say whether the length includes those 8 bytes. Header bytes 4–7 hold the size of blocks and bytes 16 (reserved,00), 17–19 are reserved. An unused block holds a pointer to the next free block (bytes 0–3) and to the next used block (bytes 4–7). The end-of-text mark is0D 0Aand line breaks are8D 0A. The notes mark dBASE III files with block length 1..fpt, Visual FoxPro (Microsoft): numbers big-endian. Header, 512 bytes: bytes 0–3 next free block, 4–5 unused, 6–7 block size. A memo’s position is block number × block size. Each memo starts with a 4-byte block signature (0 picture, 1 text) and a 4-byte length, then the data. The signature and length are big-endian too.SET BLOCKSIZE TO 0sets the block size to 1. All memo blocks start at block boundaries and one memo can span several blocks.