Board index » delphi » How do I Add a field to an existing table with data

How do I Add a field to an existing table with data

Hi,
    Does anyone know how to add / delete a field to an existing paradox
table (which already has data in it) from within delphi, without destroying
the data in the other fields.

I have looked at adding a field to the fielddefs collection of a TTable, but
there is no restructure option only create table.  Surely delphi does not
restrict you to only creating new tables ???????

Can ANYONE please help me....

regards

Matt.

 

Re:How do I Add a field to an existing table with data


When I modify existing applications I often use Database Desktop (installed
on user's machine) and restructure table. Deleting one field will not delete
other fields.
I don't know exact method/function to delete the field by code, but I'm very
sure it must exist something like DBiDeleteFieldblahblah or like :)
Look into help files for BDE.

Re:How do I Add a field to an existing table with data


Hi Wahlummie,
The easiest way I can think of is to use query with
ALTER TABLE "MYTABLE" DROP FIELD1
or
ALTER TABLE "MYTABLE" ADD FIELD1 SMALLINT
SQL. statement.
Keep in mind, however, that in the case the altered table is
master table involved in ref. integrity, the modification could fail.
--
Roman
KRE...@mbox.cesnet.cz
(please remove STOPSPAM. in header]

Quote
wahlummie wrote in message

<884081345.21899.0.nnrp-05.c1ed3...@news.demon.co.uk>...
Quote
>Hi,
>    Does anyone know how to add / delete a field to an existing paradox
>table (which already has data in it) from within delphi, without destroying
>the data in the other fields.

>I have looked at adding a field to the fielddefs collection of a TTable,
but
>there is no restructure option only create table.  Surely delphi does not
>restrict you to only creating new tables ???????

>Can ANYONE please help me....

>regards

>Matt.

Re:How do I Add a field to an existing table with data


The easy way is to use a TQuery component and the SQL ALTER TABLE
command to add a column to the table.

Bill

(Sorry but TeamB cannot answer support questions received via email.)
(To send me email for any other reason remove .nospam from my address.)

Other Threads