|
<< Click to Display Table of Contents >> dBASE: Reverse SQL CREATE |
![]() ![]()
|
This is an example from the dBASE level 5 table animals.dbf from the DBDemos database.

PdxEditor screen print: SQL CREATE TABLE for dBASE table animals.dbf - SIZE being an SQL Reserved Word needing the double quote qualifiers.
As indexes cannot be specified in BDE CREATE TABLE statements, indexes are specified separately enclosed within comment markers, and thus have to be created separately via
CREATE [UNIQUE] [ASC | DESC] INDEX IndexName ON TableName (FieldName);
or for the table shown as
CREATE INDEX Name ON animals.dbf (Name);
Though you may choose to specify fields as SQL DECIMAL(s,p), the reverse CREATE will use the general SMALLINT, INTEGER and FLOAT to specify numeric fields - see also SQL to dBASE to SQL and SQL data type translation.
Until the advent of the dBASE 7 table format, dBASE had no support for validity checks (as e.g. Required field) or specialized Primary Indexes, though for the table shown, a decent substitute may be created like:
CREATE UNIQUE ASC INDEX idxName ON animals (animals."Name");
Though technically different from the Paradox Primary Key fields, with dBASE 7 Primary Keys may be specified as:
CREATE TABLE animals (
NAME VARCHAR(10)
, animals."SIZE" SMALLINT
, WEIGHT SMALLINT
, AREA VARCHAR(20)
, BMP BLOB(1,2)
, PRIMARY KEY (animals."NAME")
);
where the resulting table when created automatically will propagate to the dBASE 7 table format to comply with the PRIMARY KEY instruction.
Also, the dBASE format, when specifying compound* indexes, it uses "Expression indexes" specifying the multiple columns differently from most other database systems (including Paradox using field lists for specifications).
Thus compound dBASE indexes are not compatible with BDE Local SQL, and likewise Local SQL cannot specify or report this kind of dBASE indexes.
*: Elsewhere also named composite or complex indexes.
Example from Borland Database Desktop specifying "Expressions index" for a dBASE IV table:
