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



ALTER TABLE Statement
Previous  Top  Next


Introduction

The ALTER TABLE statement is used to modify a structure of the existing table.

Syntax

ALTER TABLE [MEMORY] table_name ADD
(
column_name data_type [(dimensions)] [NOT NULL]
[,column_name data_type [(dimensions)] [NOT NULL]...]
[, Password "text_pass" ]
[,PRIMARY KEY (column_name [, column_name...])]
[,AutoIndexes | NoAutoIndexes]
)

ALTER TABLE [MEMORY] table_name MODIFY
(
column_name data_type [(dimensions)] [NOT NULL]
[,column_name data_type [(dimensions)] [NOT NULL]...]
[,Password 'old_pass' ]
[,New Password 'new_pass' ]
[,BlobCompressionLevel None | Fastest | Default | Max ]
[,BlobBlockSize 512 ]
[,LastAutoInc 0 ]
[,PRIMARY KEY (column_name [, column_name...])]
[,AutoIndexes | NoAutoIndexes]
)

ALTER TABLE [MEMORY] table_name DROP
(
column_name [,column_name...]
[, Password "text_pass" ]
[, PRIMARY KEY (column_name [, column_name...])]

)


Use ALTER TABLE to modify a structure of the existing table.
MEMORY option specifies that in-memory table will be created.
The ADD clause is used to add new columns to the table.

The MODIFY clause is used to modify columns definitions.
Note: EasyTable always tries to keep existing values for the modified columns when it possible.
However, some type of conversions causes data losses - for example, if you will convert string column to the integer one, all values that cannot be converted to integer will be replaced with NULL values.
To decrypt the encrypted table New Password parameter value should be a blank string.

The DROP clause is used to remove columns from the table.

Here is an example:

ALTER TABLE Test MODIFY
(
Text String(300)
,CurrentDate DateTime
,Password '123'
,New Password '1'
,BlobCompressionLevel Max
,BlobBlockSize 128
,LastAutoInc 2000
);

ALTER TABLE Test DROP (Numeric,Password '2');

ALTER TABLE Test ADD (NewField WideString(500),Password '2');



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