Creating and altering tables

Creating tables and altering the structure of existing tables is accomplished through the CreateTable and AlterTable methods of the TDBISAMTable component. Moto g data recovery software The properties used by the CreateTable and AlterTable methods include the FieldDefs, IndexDefs, DatabaseName, TableName, and Exists properties.

There are four basic steps that need to be completed when creating a table or altering the structure of an existing table.


Data recovery windows 10 They are as follows:

The FieldDefs property is used to specify which fields to define for the new or existing table. Database youtube The FieldDefs property is a list of TDBISAMFieldDef objects, each of which contains information about the fields that make up the table. H2 database console You may add new TDBISAMFieldDef objects using the Add method. Database browser There are two different versions of the Add method. Database help One is for use when creating a table and does not accept a FieldNo parameter as the first parameter, and the other is for use when altering the structure of an existing table and requires that you specify the FieldNo parameter as the first parameter. Database vendors The reason for this difference is that DBISAM uses field numbers (1-based) to distinguish between existing fields in a table and new fields being added. Database key It also uses field numbers in addition to the index position (0-based) of a field definition in the FieldDefs property to determine if a field has been moved in the structure, but still exists. Data recovery live cd The use of field numbers also allows for the renaming of existing fields in a table without losing data when altering the structure of an existing table.

The field definitions represented by the FieldDefs property can have gaps in the field numbers when altering the structure of an existing table. Data recovery clean room The is because it is possible that a given field definition has been deleted, which means that its field number would not be present anywhere in the field definitions. Database view This type of condition is exactly what indicates to DBISAM that the field should be removed from the table structure.

An index position is 0-based, meaning that the first field definition is at index position 0, the second field definition at index position 1, etc. Data recovery fort lauderdale When creating a table or altering the structure of an existing table, the index position represents the desired physical position of the field definition in the table after the table creation or alteration takes place.

When altering the structure of an existing table, you can move field definitions around to different index positions and leave their field numbers intact. Data recovery equipment tools This will indicate to DBISAM that the field has simply moved its position in the structure of the table. Data recovery lab You can also use the Insert method to insert a field definition at a specific index position. Data recovery online Like the Add method, there are two versions of the Insert method, one with a FieldNo parameter for use when altering the structure of an existing table and one without for use when creating a table.

The IndexDefs property is used to specify which indexes to define for the new or existing table. Database union The IndexDefs property is a list of TDBISAMIndexDef objects, each of which contains information about the indexes defined for the table. Data recovery houston You may add new TDBISAMIndexDef objects using the Add method. 7m database soccer basketball Unlike field definitions, DBISAM uses the index name to distinguish between different index definitions, and their index position in the list of index definitions is irrelevant.

Keep in mind that Linux has case-sensitive file names when specifying the TableName property in Kylix. Create database link Since the logical table name is used in DBISAM as part of the physical files that make up the table (.dat for data, .idx for indexes, and .blb for BLOBs), the character casing of the table name matters greatly with Kylix.

After defining the field and index definitions and setting the database and table information, you can call the CreateTable method to create the actual table. Database form It is usually good practice to also examine the Exists property of the TDBISAMTable component first to make sure that you don’t attempt to overwrite an existing table. Data recovery process If you do attempt to overwrite an existing table an EDBISAMEngineError exception will be raised. Database training The error code given when a table create fails due to the table already existing is 13060 and is defined as DBISAM_TABLEEXISTS in the dbisamcn unit (Delphi and Kylix) or dbisamcn header file (C++Builder).

The CreateTable method can be called without any parameters or you may specify many different parameters that set table-wide information for the table such as its description, locale, etc. Data recovery hardware The following example shows how to create the local “customer” table using the CreateTable method without any additional parameters:

After defining the field and index definitions and setting the database and table information, you can call the AlterTable method to alter the structure of the existing table. Best database software It is usually good practice to also examine the Exists property of the TDBISAMTable component first to make sure that you don’t attempt to alter the structure of a non-existent table. Database gui If you do attempt to alter the structure of a non-existent table an EDBISAMEngineError exception will be raised. Data recovery technician The error code given when a table open fails due to the table not being present is 11010 and is defined as DBISAM_OSENOENT in the dbisamcn unit (Delphi and Kylix) or dbisamcn header file (C++Builder). Database engine tuning advisor Also, DBISAM requires exclusive access to the table during the process of altering the table’s structure and an EDBISAMEngineError exception will be raised if the table cannot be opened exclusively. Data recovery rates The error code given when a table open fails due to access problems is 11013 and is defined as DBISAM_OSEACCES in the dbisamcn unit (Delphi and Kylix) or dbisamcn header file (C++Builder).

The AlterTable method can be called without any parameters or you may specify many different parameters that set table-wide information for the table such as its description, locale, etc. Database developer salary If you wish to leave all of the table-wide information as it currently exists in the table, then you should pass the following TDBISAMTable properties to the AlterTable method (in this order):

These properties can be read from the exising table without requiring the table to be opened first. Database backup and recovery However, in order for DBISAM to read the Password property of an encrypted DBISAM table or alter the structure of an encrypted DBISAM table in general, the password for the encrypted table must already be defined for the current session or else it must be provided via an event handler assigned to the TDBISAMSession OnPassword event or by the user via the dialog that will be displayed by DBISAM if an event handler is not assigned to this event for the current session. Yale b database Please see the Opening Tables topic for more information.

Calling the basic version of the AlterTable method without any parameters is not the same as calling the AlterTable method with the above properties as parameters. Sybase database Calling the AlterTable method with no parameters instructs DBISAM to use the default parameters for all table-wide information.

The following example shows how to alter the local “customer” table’s structure using the AlterTable method without any additional parameters. Database design In this example we want to add a LastSaleAmount (a BCD field) to this table’s structure in front of the LastSaleDate field and then add a secondary index on this new LastSaleAmount field to speed up filtering in SQL queries:

In addition to using the TDBISAMTable CreateTable and AlterTable methods for creating and altering the structure of existing tables, DBISAM also allows the use of the CREATE TABLE and ALTER TABLE SQL statements.

Unless the SuppressBackups parameter to the AlterTable method is set to True (default is False), DBISAM will make backups of a table’s physical files before altering the structure of a table, except when the following four conditions exist:

1) The only alteration of the structure that has taken place has been a change in the table description or the user-defined major or minor version numbers.

In all other cases DBISAM will make a backup of each physical file associated with the table whose structure is being altered. Database 3 normal forms Each physical file will have the same root table name but with a different extension. Database for dummies These extensions are as follows:

There is one exception – if the alteration of the table structure has only changed one of the primary or secondary indexes or the full text index (by changing the full text indexing parameters), then only the index file will be backed up. A database is a collection of This is designed in this fashion to speed up the process of altering a table’s structure when the only change has been to the index definitions.

To restore these files in case of a mistake, simply rename them to the proper extension or copy them to the original file names. Library database Also, these backup files will get overwritten without warning for each structure alteration that occurs on the table. Database node If you need the backup files for future use it’s best to copy them to a separate directory where they will be safe.

The file extensions described above are the default extensions and can be changed. Data recovery after format Please see the DBISAM Architecture and Customizing the Engine topics for more information.

To take care of tracking the progress of the table structure alteration, we have provided the TDBISAMTable and TDBISAMQuery OnAlterProgress events.

To take care of dealing with data loss during the alteration of a table’s structure, we have provided the TDBISAMTable and TDBISAMQuery OnDataLost events. Database 2015 The OnDataLost event is used to track when data is lost due to field conversions between incompatible types, field constraint failures, field deletions, or key violations resulting from changes in the primary index definition or unique secondary index definitions.

banner