NexusDB supports SQL DDL, which means that you may Create Tables and Indices through SQL. Here are SQL DDL statements to create the Products Table:

CREATE TABLE PRODUCTS

(

       PRODUCTID AUTOINC NOT NULL PRIMARY KEY,

       NAME VARCHAR(64) NOT NULL,

       RETAILPRICE MONEY NOT NULL,

       WHOLESALEPRICE MONEY NOT NULL,

       MANUFACTURERID INTEGER NOT NULL,

       PRODUCTNUMBER VARCHAR(64) NULL,

       DESCRIPTION TEXT,

       THUMBNAIL IMAGE,

       PRODUCTIMAGE IMAGE,

       CREATED DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,

       MODIFIED DATETIME NOT NULL

);

CREATE INDEX I_NAME ON PRODUCTS (NAME IGNORE CASE);

CREATE INDEX I_MANUFACTURERID ON PRODUCTS (MANUFACTURERID);

CREATE INDEX I_PRODUCTNUMBER ON PRODUCTS (PRODUCTNUMBER);

By using standard SQL data types, the Products table that is created from the SQL DDL, is not exactly the same as the one created by the Data Dictionary code. There are four differences:

The NAME and PRODUCTNUMBER columns are of type nxtShortString because they are of type VARCHAR with a length less than 256. The Data Dictionary code sets the NAME and PRODUCTNUMBER columns as type nxtNullString. In SQL the nxtNullString type may be forced by declaring the type as NULLSTRING.
The MANUFACTURERID is an nxtInt32, which is a signed 32-bit integer rather than the nxtWord32 type (unsigned 32-bit integer) that the Data Dictionary code produces. In SQL, the nxtWord32 type can be used by declaring the type as DWORD.
The Primary Key index that is created by the PRIMARY KEY specifier on the PRODUCTID column creates an auto named primary key (e.g. key0). The Data Dictionary code names this index "PK_PRODUCTID".
Descriptions for the Indices are not set in the SQL DDL.

The full SQL DDL is covered in detail in the SQL reference chapter. Using SQL DDL is the most database neutral Table creation method.

Home | Site Contents | Documentation | NexusDB Manual V4 | Delphi Guide | Code Examples & Fragments | How to create Tables?