下面的代码演示了怎样在运行期动态地创建一个表格:
var NewTable:
TTable;
NewIndexOptions: TIndexOptions;
Begin
NewTable := TTable.Create;
NewIndexOptions := [ixPrimary, ixUnique];
With NewTable Do
Begin
Active := False;
DatabaseName := 'DBDEMOS';
TableName := Edit1.Text;
TableType := ttDefault;
FieldDefs.Clear;
FieldDefs.Add(Edit2.Text, ftInteger, 0, False);
FieldDefs.Add(Edit3.Text, ftInteger, 0, False);
IndexDefs.Clear;
IndexDefs.Add('PrimaryIndex? Edit2.Text, NewIndexOptions);
End;
CreateTable;
End;