SQL simple -> Basic Data Definition syntax for Paradox, dBase

Create Table:

Examples:
CREATE TABLE 'MyEmp.db'
(EmpID Autoinc,
DeptNo SMALLINT,
FirstName CHAR(20),
LastName CHAR(30),
PositionDef VARCHAR(50),
DateOfBirth DATE,
TimeOfBirth TIME,
ManagerYN Boolean,
WorkTotal Float (10,2),
Salary Money,
PRIMARY KEY (EmpID));

/* The statement for a dBASE table should omit the PRIMARY KEY definition: */

CREATE TABLE "employee.dbf"
(LAST_NAME CHAR(20),
FIRST_NAME CHAR(15),
SALARY NUMERIC(10,2),
DEPT_NO SMALLINT);

Create index:

Primary Index of Paradox table can not be created using CREATE INDEX statement, it is created as a part of PRIMARY KEY definition. On the other hand it is not possible to create column constarints via CREATE TABLE table definition (like NOT NULL or CHECK), so one of the possible ways to enforce Paradox table structure is to add secondary indexies after table is created.

Important [!] frequently you will need to use full file path for the paradox table in the DDL statements.

Examples:
CREATE UNIQUE INDEX indPerson ON
'D:\datafiles\MyEmp.db'
(FirstName, LastName)

CREATE DESCENDING INDEX indDeptNo ON
'D:\datafiles\MyEmp.db' (DeptNo)

DROP TABLE 'D:\datafiles\MyEmp.db'

DROP INDEX "MyEmp.db".PRIMARY

DROP INDEX "MyEmp.db".indLastName


More Examples:
/* the following statement adds a column to a table: */
ALTER TABLE "employee.dbf" ADD BUILDING_NO SMALLINT;

/* the next statement drops two columns from a Paradox table: */

ALTER TABLE "employee.db" DROP LAST_NAME, DROP FIRST_NAME;

/* ADD and DROP operations can be combined in a single statement: */

ALTER TABLE "employee.dbf" DROP LAST_NAME,
DROP FIRST_NAME, ADD FULL_NAME CHAR[30];


sqlexamples.info