Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Index

Status
Not open for further replies.

mimosa

IS-IT--Management
Apr 4, 2002
25
US
Hello,
I want to create any index by programming for existing table
is it possible?
thanks for any help

 
yes, check out the MSDN for INDEX.

Creates an index file to display and access table records in a logical order.

Syntax

INDEX ON eExpression TO IDXFileName | TAG TagName [OF CDXFileName]
[FOR lExpression]
[COMPACT]
[ASCENDING | DESCENDING]
[UNIQUE | CANDIDATE]
[ADDITIVE]

HTH,
Weedz (Wietze Veld) They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best. - Steve McConnell
 
Mimosa,
You were a little short of the info we need to help you, so to expand on Weedz statement.

There are 2 types of indexes Compound (CDX) and individual(IDX).
The differences are:

CDX - You need to have the DBF file opened Exclusive and sometimes that is not possible. A CDX index is recorded in the header of the database and opend automatically every time you open the DBF. CDX Files will automatically update as you enter records into the DBF.
INDEX ON eExpression TAG TagName [OF CDXFileName]
[FOR lExpression]
[COMPACT]
[ASCENDING | DESCENDING]
[UNIQUE | CANDIDATE]
[ADDITIVE]

IDX - You can create it with a DBF opened shared or noupdate.
IDX files are independent of the DBF.
IDX files WILL NOT open automatically when you the dbf.
IDX files WILL NOT automatically update unless you open them.
IDX files are good for a fast temp order to a dbf that can be thrown away after use.
INDEX ON eExpression TO IDXFileName
[FOR lExpression]
example
USE CUSTOMER order ID shared && there is a CDX on CUSTOMER that was opened
index on CUSTOMER.ADDRESS to C:\TEMP\CUSTADDR.IDX for !deleted()
set index to C:\TEMP\CUSTADDR.IDX
seek "123"
report form xxxx while CUSTOMER.ADDRESS = "123"
set index to
delete file C:\TEMP\CUSTADDR.IDX
press on with life.

Hope this helps you. David W. Grewe
Dave@internationalbid.com
ICQ VFP ActiveList #46145644
 
Hello.

The previous answers are very good. In completion:

If your table is included in a database, you can use
ALTER TABLE tablename ADD PRIMARY KEY index_expression TAG tag_name.

There is no way to add a primary index using the INDEX command.

Hope this helps Grigore Dolghin
Class Software
Bucharest, Romania
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top