amedoo3000 said:
No, you don't. You asked:
amedoo3000 said:
how can i copy the INDEXES from table to [highlight #FCE94F]another[/highlight] table
And this is not what COPY INDEXES offers, it turns IDX into CDX for the
same table.
Notice copying an index including its data can only work out and result in an index pointing a seek inside this index to the correct records, if not only the index but also the data matches. For the fourth or fifth time from three persons, I point out the command you could use while you create the table data copy, too, is SELECT source and then COPY TO target.DBF WITH CDX.
It's clear that your situation is having two tables. You can't copy over the index from one to another table, it's not sufficient that the structure is the same.
What you can do when you have other data, just partial data or even an empty second DBF is what Mike showed you in his first answer, you can copy over the index
expressions and recreate the same index tag names with the same expression to let the same SEEK/INDEXSEEK or rushmore optimizations work with the second table, too.
There is neither a source nor a target alias as option of the COPY INDEXES command. You miss to understand the syntax description. You specify tag names associated with IDX file names and a CDX file name as target. The best you could do is copy from table1tag1.idx, table1tag2.idx to table2.cdx, but the CDX you create that way won't work! It's not designed for table2, even if table2 is a structural copy. The index data points to records in table1.dbf and all the record numbers would be wrong for table2, SEEKing in that cdx would guide you to totally wrong records.
Again, in your situation you have a simpler solution if you go back to the step of creating the second table with data AND cdx at the same time with COPY TO WITH CDX or you have to iterate all indexes of the first table and recreate them with INDEX ON, as far as that's possible (not with primary indexes). You better change the code creating the second table to do that with COPY TO WITH CDX as that's the step where you can copy the indexes, all of them, even primary.
Bye, Olaf.
Olaf Doschke Software Engineering