Board index » delphi » Remove a primary index
Glenn Greatwood
![]() Delphi Developer |
Glenn Greatwood
![]() Delphi Developer |
Remove a primary index2006-07-27 12:14:13 AM delphi106 Hi Delphi4 with Paradox tables I have a Paradox table with a field called 'ID', this is a primary Index. I now need to remove this primary index but leave the field intact with the data...is this possible using AlterTable statement? Many thanks Kind Regards Glenn Greatwood |
Bill Todd
![]() Delphi Developer |
2006-07-27 12:49:46 AM
Re:Remove a primary index
See DROP INDEX in the Local SQL help file.
-- Bill Todd (TeamB) |
srdaniel
![]() Delphi Developer |
2006-07-27 03:02:25 AM
Re:Remove a primary index
DropIndex( 'alias', 'tablename', '' ); // Will drop the primary
index....(I think....) function DropIndex( Alias, Table, IndexName: String ): Boolean; var ATable: TTable; begin Result := True; ATable := TTable.Create( nil ); try ATable.DatabaseName := Alias; ATable.TableName := Table; ATable.DeleteIndex( IndexName ); finally FreeAndNil( ATable ); end; end; Glenn Greatwood writes: QuoteHi |
Glenn Greatwood
![]() Delphi Developer |
2006-07-27 03:08:29 PM
Re:Remove a primary index
That's great chaps thanks, next problem is I now need to define a new
primary index? The table name is scheduler.db and the fieldname for the primary index is GUIDID Amongst other methods, I have tried the following that doesn't work (capability not supported) //create new primary index With UpdateTables do// begin Sql.Clear; Sql.Add('Alter Table '+Chr(39)+Data+Chr(39)); Sql.Add('ADD PRIMARY KEY (GUIDID)'); ExecSql; end; Where UpdateTables is a TQuery and Data is a string set to 'cxSchedulerTable.DB'. Many thanks for your time Glenn "Brian Bushay TeamB" <XXXX@XXXXX.COM>writes Quote
|
Bill Todd
![]() Delphi Developer |
2006-07-27 10:21:48 PM
Re:Remove a primary index
See TTable.AddIndex in the on-line help.
-- Bill Todd (TeamB) |
Glenn Greatwood
![]() Delphi Developer |
2006-07-28 03:25:03 PM
Re:Remove a primary index
Thanks Bill
I can call ScheduleItems.AddIndex('Test', 'GUIDID',[], 'GUIDID'); (where ScheduleItems is a TTable) and create a secondary index called test....however what I need is a primary index, if that is the right terminology, or a keyed index? (I can achieve what I require using Database Desktop and pushing the space bar in the key column when in restructure). Thanks Glenn "Bill Todd" <XXXX@XXXXX.COM>writes QuoteSee TTable.AddIndex in the on-line help. |
Bill Todd
![]() Delphi Developer |
2006-07-28 09:47:30 PM
Re:Remove a primary index
The primary index for a Paradox table has no name so if you pass an
empty string as the index name you will get a primary index. -- Bill Todd (TeamB) |
Glenn Greatwood
![]() Delphi Developer |
2006-07-29 12:04:10 AM
Re:Remove a primary index
Thank you Bill
That works and I am one step nearer, however the field I wish to use as my primary index is only just created in my code immediately before my AddIndex statement and is so at the end of the 'Field Roster' definition. Can I programmatically move it to the top of the 'Field Roster' somehow? as this is where the primary index must be? Thanks Glenn "Bill Todd" <XXXX@XXXXX.COM>writes QuoteThe primary index for a Paradox table has no name so if you pass an |
Bill Todd
![]() Delphi Developer |
2006-07-29 12:43:09 AM
Re:Remove a primary index
Glenn Greatwood writes:
QuoteCan I programmatically move it to the top of the 'Field Roster' info.borland.com/devsupport/bde/bdeapiex. If I was trying to do this I would search for an example using Google and Google Groups and just copy it. -- Bill Todd (TeamB) |
Rick Carter
![]() Delphi Developer |
2006-07-29 01:20:42 AM
Re:Remove a primary index
The primary index cannot be dropped and recreated while secondary indexes
exist. you will have to: -Drop all secondary indexes. -Drop the primary index. -Create a new primary index. -Recreate the secondary indexes. Sorry if I am stating the obvious, but it sounds like you were trying to do things differently from that. Rick Carter XXXX@XXXXX.COM Chair, Delphi/Paradox SIG, Cincinnati PC Users Group --- posted by geoForum on delphi.newswhat.com |