TurboDB VCL Component Library

Altering a Table at Run-time

See also

Previous  Top  Next

Use the AlterTable method to restructure a database table at runtime. AlterTable uses the FieldDefsTdb property to determine the field definitions of the altered table. TurboDB keeps all field values if possible, even if the field type is changed or the field is renamed. The structure of the altered table is set in the same way as for creating the table. Altering a table can also be used to change the level of a table or to modify its password or key.

Note: Altering a table may result in loosing data. Especially if you delete columns of a table or if you shorten alphanumeric fields, the data stored in the table is lost.

Note: If there should be any problem during the restructuring and your program crashes, your data is not lost. The original tables are renamed to ~TableName before the restructuring begins. If a problem occurs you just have to rename this file to restore all your original data.

The example shows how to change the encryption key of a table at runtime:

TdbTable4.EncryptionMethod := temBlowfish;

TdbTable4.Password := 'dataweb';