Board index » off-topic » Re: Add indexed fields
|
Bill Todd
Delphi Developer |
|
Bill Todd
Delphi Developer |
Re: Add indexed fields2004-11-18 09:37:51 PM off-topic10 use the SQL ALTER TABLE command to add the fields and the CREATE INDEX command to add the index. See the Local SQL help file for details. -- Bill (TeamB) TeamB cannot answer questions received via email Stephen M wrote: QuoteHi, |
| Stephen M
Delphi Developer |
2004-11-18 09:55:25 PM
Re:Re: Add indexed fields
Hi,
Using Delphi 7, BDE and paradox tables, Is there a way to add indexed fields (like datestamp, integer) in an existing table at run time? Thank's |
| Stephen M
Delphi Developer |
2004-11-19 04:26:19 AM
Re:Re: Add indexed fields
Hi,
Ok, I did that but is possible to add the new fields as part of the primary key? ?"Bill Todd" < XXXX@XXXXX.COM >έγραψε στ?μήνυμα Quoteuse the SQL ALTER TABLE command to add the fields and the CREATE INDEX {smallsort} |
| Quinn Wildman
Delphi Developer |
2004-11-19 08:32:19 AM
Re:Re: Add indexed fields
Here's soon good solid advice. Rethink your design...
It's better that you make ALL your keys be single field non meaningfull data. I say this regardless of the database you use. All database systems have a way to do this. With Paradox tables typically you use an autoinc field. Do this and you will save yourself headaches down the road. Stephen M wrote: QuoteHi, |
| Steven Green
Delphi Developer |
2004-11-19 09:13:02 AM
Re:Re: Add indexed fields
Quinn Wildman wrote:
QuoteWith Paradox tables typically you use an autoinc field. Do this and you will better to "roll your own" or use somebody else's "next number" process.. it's too easy.. Diamond Software Group www.diamondsg.com/main.htm Paradox Support & Sales - Corel CTech Paradox --------------------------------------------------- Diamond Sports Gems www.diamondsg.com/gemsmain.htm Trading Cards and other Sports Memorabilia --------------------------------------------------- |
| Stephen M
Delphi Developer |
2004-11-19 05:28:13 PM
Re:Re: Add indexed fields
Hi,
The problem is that the exixting keys MUST stay as they are (because of master/detail relations and other features that the application provides etc.). Two new fields (TIMESTAMP and INTEGER) must be added as the last keys of the primary key. I am considering DbiDoRestructure function of the BDE as an alternative way of SQL ALTER TABLE. Now I am searching for more info... |
| Quinn Wildman
Delphi Developer |
2004-11-20 01:48:13 AM
Re:Re: Add indexed fields
Autoinc isn't the only way to generate an single field non meaningfull
key. Just make sure you create a single field non meaningful key. How you decide to implement this is up to you. Steven Green wrote: QuoteQuinn Wildman wrote: |
| C P
Delphi Developer |
2004-11-20 02:40:16 AM
Re:Re: Add indexed fields
With Paradox, the fields in your primary key must be the first fields in
your table (and have the same order in the table that they do in the primary key). Probably the easiest thing would be to create a new table with the structure you want, copy the data (adding in values for the 2 extra fields) from the old to the new table, delete the old table, and then rename the new table. While DbiDoRestructure will allow you to change your primary key, I don't think it can re-arrange the order of columns which is something you'd need to do in order to add brand new columns to your primary key. |
