EasyTable: Single-File Embedded Database,
a BDE replacement for Delphi and C++Builder



CREATE TABLE Statement

Previous  Top  Next


Introduction

The CREATE TABLE statement is used to create a new table.

Syntax

CREATE TABLE [MEMORY] table_name
(
column_name data_type [(dimensions)] [NOT NULL]
[,column_name data_type [(dimensions)] [NOT NULL]...]
[,Password "text_pass" ]
[,BlobCompressionLevel None | Fastest | Default | Max ]
[,BlobBlockSize 512 ]
[,LastAutoInc 0 ]
[,AutoIndexes | NoAutoIndexes]
)

Use CREATE TABLE to create table with specified structure.
MEMORY option specifies that in-memory table will be created.
The column_name is a name of the column. The data_type can be one of the following:

Data type
Description
AutoInc
Auto incremental 32-bit unsigned integer.
BCD
Floating point number.
BLOB
Binary Large Object - variable length binary data
Bytes ( length )
Fixed length binary data
Currency
Floating point number.
Date
Date value
DateTime
DateTime value.
Float
Floating point number.
FmtMemo
Formatted memo - variable length string in RTF format.
Graphic
Binary data for storing pictures.
Integer
32-bit signed integer.
LargeInt
64-bit signed integer.
Logical
Boolean value.
Memo
Variable length string in plain text format
SmallInt
16-bit signed integer
String ( length )
Fixed length string (may be up to 2^32 symbols)
Time
Time value.
WideString ( length )
Fixed length Unicode string (may be up to 2^32 symbols)
Word
16-bit unsigned integer.


The dimensions is a size of the column value in bytes. Use it with bytes, string or wide string data types.
Use NOT NULL option to specify columns with required not empty values.

Use Password option to specify password for encrypted table.
Specify compression level for storing BLOB values (BLOB,FmtMemo,Memo,Graphic) via BlobCompressionLevel option.
The BlobBlockSize is the size in bytes of one block for storing BLOB values. Minimum value 100 bytes, default value 512 bytes.
LastAutoIncValue is default value for auto incremental columns.
Also, you can enable automatical indexes creation for all fields. Use option AutoIndexes to create auto-indexes and NoAutoIndexes option (default) to miss automatical indexes creation.

Here is an example:

CREATE TABLE Test
(
ID AutoInc
,Text String(500)
,Numeric Float
,Money Currency
,CurrentDate Date
,Picture Graphic
,Password '1'
,BlobCompressionLevel Fastest
,BlobBlockSize 1024
,LastAutoInc 1000
PRIMARY KEY (id)
);


Note:
If the table with the specified name already exists, CREATE TABLE will raise an exception.



© AidAim Software EasyTable: Easytable Ben Delphi Database Single File Bde Replacemen