Minggu, 18 Maret 2012

DBF File structure


Understanding Digital Image Formats

There are many digital image formats available for you to use, but only some of them are optimized for web use. For example, the TIFF image format is not designed for web use; it’s used for printing. Examples of image formats for the web are JPEG, PNG, GIF, and SVG.
Why are certain image formats suitable for the web, while others aren’t? Because images on the web must be optimized and highly compressed so that they don’t get too huge.
Some digital image formats, especially those designed for print (such as TIFF) are so unnecessarily high in resolution, metadata, and color-richness — which all become irrelevant when viewed in computer  monitors — that they are too big in file size for web use.


DBF file consists of a header record and data records. The header record defines the structure of dbf file and contains any other information related to the table. The header record starts at file position zero. Data records follow the header, in consecutive bytes, and contain the actual text of the fields.
Note   The data in dbf file starts at the position indicated in bytes 8 to 9 of the header record. Data records begin with a delete flag byte. If this byte is an ASCII space (0x20), the record is not deleted. If the first byte is an asterisk (0x2A), the record is deleted. The data from the fields named in the field subrecords follows the delete flag.
The length of a record, in bytes, is determined by summing the defined lengths of all fields. Integers in dbf files are stored with the least significant byte first.

DBF File Header

Byte offsetDescription
0DBF File type:
0x02   FoxBASE
0x03   FoxBASE+/Dbase III plus, no memo
0x30   Visual FoxPro
0x31   Visual FoxPro, autoincrement enabled
0x32   Visual FoxPro with field type Varchar or Varbinary
0x43   dBASE IV SQL table files, no memo
0x63   dBASE IV SQL system files, no memo
0x83   FoxBASE+/dBASE III PLUS, with memo
0x8B   dBASE IV with memo
0xCB   dBASE IV SQL table files, with memo
0xF5   FoxPro 2.x (or earlier) with memo
0xE5   HiPer-Six format with SMT memo file
0xFB   FoxBASE
1 - 3Last update (YYMMDD)
4 – 7Number of records in file
8 – 9Position of first data record
10 – 11Length of one data record, including delete flag
12 – 27Reserved
28Table flags:
0x01   file has a structural .cdx
0x02   file has a Memo field
0x04   file is a database (.dbc)
This byte can contain the sum of any of the above values. For example, the value 0x03 indicates the table has a structural .cdx and a Memo field.
29Code page mark
30 – 31Reserved, contains 0x00
32 – nField subrecords
The number of fields determines the number of field subrecords. One field subrecord exists for each field in the table.
n+1Header record terminator (0x0D)
n+2 to n+264Visual Foxpro only: A 263-byte range that contains the backlink, which is the relative path of an associated database (.dbc) file, information. If the first byte is 0x00, the file is not associated with a database. Therefore, database files always contain 0x00.

Field Subrecords Structure

Byte offsetDescription
0 – 10Field name with a maximum of 10 characters. If less than 10, it is padded with null characters (0x00).
11Field type:
C   –   Character
Y   –   Currency
N   –   Numeric
F   –   Float
D   –   Date
T   –   DateTime
B   –   Double
I   –   Integer
L   –   Logical
M   – Memo
G   – General
C   –   Character (binary)
M   –   Memo (binary)
P   –   Picture
+   –   Autoincrement (dBase Level 7)
O   –   Double (dBase Level 7)
@   –   Timestamp (dBase Level 7)
12 – 15Displacement of field in record
16Length of field (in bytes)
17Number of decimal places
18Field flags:
0x01   System Column (not visible to user)
0x02   Column can store null values
0x04   Binary column (for CHAR and MEMO only)
0x06   (0x02+0x04) When a field is NULL and binary (Integer, Currency, and Character/Memo fields)
0x0C   Column is autoincrementing
19 - 22Value of autoincrement Next value
23Value of autoincrement Step value
24 – 31Reserved



Tidak ada komentar:

Posting Komentar