|
<< Click to Display Table of Contents >> SQL to dBASE to SQL |
![]() ![]()
|
First of all, the basic dBASE numeric field type until dBASE 7 has as the only numeric field option been the text based field NUMERIC.
However, dBASE 7 tables may still use the NUMERIC field types too.
This field type is used for any size and type of numeric data, float as well as integer values, positive as well as negative numbers, and only specifying its scope via the size (s) and precision (p) parameters.
With SQL it may be specified as:
FieldName DECIMAL(s,p), e.g. as DECIMAL(6,2).
Considering the scope of the general numeric types: |
|
Smallint (for Small Integer or Short): |
16-bit signed integer ranging from -32.768 to 32.767 (5 digits) |
Integer (for Long Integer or Long): |
32-bit signed integer ranging from -2.147.483.648 to 2.147.483.647 (10 digits) |
Float (for Double): |
64-bit floating point number. |
This gives the following conversions between SQL, dBASE field specs. and back to SQL field specifications:
SQL |
Max |
>> dBASE NUMERIC |
Max |
>> SQL |
DECIMAL(1,0) |
|
NUMERIC(1,0) |
9 |
SMALLINT |
DECIMAL(4,0) |
|
NUMERIC(4,0) |
9.999 |
SMALLINT |
DECIMAL(5,0) |
|
NUMERIC(5,0) |
99.999 |
INTEGER |
DECIMAL(9,0) |
|
NUMERIC(9,0) |
999.999.999 |
INTEGER |
DECIMAL(10,0) |
|
NUMERIC(10,0) |
9.999.999.999 |
FLOAT |
DECIMAL(6,2) |
|
NUMERIC(6,2) |
999.999 |
FLOAT |
SMALLINT |
32.767 |
NUMERIC(6,0) |
999.999 |
INTEGER |
INTEGER |
2.147.483.647 |
NUMERIC(11,0) |
99.999.999.999 |
FLOAT |
FLOAT |
|
NUMERIC(20,4) |
|
FLOAT |
As displayed, the maximum dBASE numeric not exceding the range of SMALLINT is NUMERIC(4,0).
Likewise the maximum dBASE numeric not exceding the range of INTEGER is NUMERIC(9,0).
So, specifying dBASE NUMERIC fields via SQL and back from dBASE to SQL, fields specified as SMALLINT may have to upsize to INTEGER and correspondingly from SQL INTEGER to dBASE NUMERIC to SQL FLOAT.
Based on this, you may see some shifts between SMALLINT, INTEGER and FLOAT when reverse generating the SQL CREATE TABLE statements.
See also dBASE Reverse SQL CREATE and Redefining a Table.