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. |
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: 01 has a production .mdx index. |
29 | 1 | Code page mark (language driver ID), such as 01 for code page 437 (DOS USA), 02 for 850 (DOS multilingual) and 03 for Windows ANSI 1252. |
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).
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 of these differ by one from the Xbase notes’ values (2F and
03…); which is right for each writer is not settled by the sources.
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: offset of the field in the record. dBASE: a memory address, of no use in files. |
16 | 1 | Field length in bytes. |
17 | 1 | Decimal places. |
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 01 when the field has a key in the production .mdx index. |
Field types
| Type | Name | Stored as |
|---|---|---|
C | Character | ASCII text, under 254 bytes in dBASE (32 KB or more in Clipper and FoxPro). |
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 set). |
D | Date | 8 characters, YYYYMMDD. |
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). |
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.
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. A memo runs over consecutive blocks and ends with two1Abytes..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..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.