CREATE TABLE SQL Command
Creates a DBF table using the specified fields. The complete syntax is:
[CODEPAGE = nCodePage]
(FieldName1 FieldType [( nFieldWidth [, nPrecision] )] [NULL | NOT NULL]
[AUTOINC [NEXTVALUE NextValue [STEP StepValue]]]
[, FieldName2 ... ] [ ... ] )
Parameters
Specifies the name of the DBF file to be created. The TABLE and DBF options are identical.
Specifies the code page to use. For the complete list of DBF code pages, see supported code pages topic.
Specifies the field name, field type, field width, and field precision (number of decimal places) to be created, respectively. Maximal field count a DBF table can contain is 255 fields. If one or more fields allow null values, the limit decreases to 254 fields.
The FieldType parameter is a single letter (or long name) indicating the field type. You can specify nFieldWidth, nPrecision, or both for some of field types. The following table lists the values for FieldType and whether you can specify nFieldWidth and nPrecision:
Field Type | Field Width | Precision | Data type |
W, Blob | – | – | Blob |
C, Char, Character | N | – | Character field of width N |
Y, Currency | – | – | Currency |
D, Date | – | – | Date |
T, DateTime | – | – | DateTime |
B, Double | – | D | Double |
G, General | – | – | General |
I, Int, Integer | – | – | Integer |
L, Logical | – | – | Logical |
M, Memo | – | – | Memo |
N, Num, Numeric | N | D | Numeric field of width N with D decimal places |
F, Float | N | D | Floating Numeric field of width N with D decimal places |
The nFieldWidth and nPrecision parameters are ignored for the Blob, Currency, Date, DateTime, General, Integer, Logical, and Memo field types. If nPrecision is not included for the Numeric or Float types, the nPrecision parameter defaults to zero (no decimal places).
Specifies whether null values are allowed in the field: NULL permits null values, NOT NULL does not allow null values. By default, NULL values are allowed (except AUTOINC fields)
Enables autoincrementing for the Integer field. NextValue specifies the start value and can be a positive or a negative value ranging from Integer range: -2,147,483,647 to 2,147,483,647. The default value is 1.
StepValue specifies the increment value for the field and can be a positive, nonzero integer value ranging from 1 to 255. The default value is 1.
Specifies one or more additional fields and attributes, and so on.
CREATE TABLE Example
Create a DBF file named "customer":
Create the same DBF file in Japanese Windows encoding and forbid NULL values in "payment" field: