How to Duplicate a TTable
December 15th, 1999
No comments
There are various ways to copy/duplicate databases. Using TBatchMover you can copy the structure and data but can’t copy the index files. Then again when you use FileCopy() you can’t copy the tables corresponding index files automatically and you have to define all the files. One of the ways to duplicate a database is to use 2 TTable components. Here’s the code:
... TableSource: TTable; TableTarget: TTable; ... TableSource.TableName := 'Source.db'; TableTarget.TableName := 'Target.db'; TableSource.StoreDefs := True; TableTarget.StoreDefs := True; TableSource.FieldDefs.Update; TableSource.IndexDefs.Update; TableTarget.FieldDefs := TableSource.FieldDefs; TableTarget.IndexDefs := TableSource.IndexDefs; TableTarget.CreateTable;