recreation of DBF indexes

recreation of DBF indexes

Post by Luca Mani » Wed, 30 Apr 1997 04:00:00



Hi,

I've found how to create/delete indexes at run-time, but I've a
problem with the MDX file.

The file is automatically created (if not already there) when I create
the first index, and automatically removed when I remove the last
index. That's fine.

But if I remove (the end user will do that for sure) the MDX from disk
while there are still indexes than Delphi refuse to open the table.

Is there a why (with VCL, no calls to BDE please) to say: ok, forget
about any indexes and files and start again from scratch ?

        Thanks, Luca.

 
 
 

recreation of DBF indexes

Post by Bart Garsse » Thu, 01 May 1997 04:00:00



> Hi,

> I've found how to create/delete indexes at run-time, but I've a
> problem with the MDX file.

> The file is automatically created (if not already there) when I create
> the first index, and automatically removed when I remove the last
> index. That's fine.

> But if I remove (the end user will do that for sure) the MDX from disk
> while there are still indexes than Delphi refuse to open the table.

> Is there a why (with VCL, no calls to BDE please) to say: ok, forget
> about any indexes and files and start again from scratch ?

>         Thanks, Luca.

There is some nice tool on the Borland site to regenerate indexes. Don't
know if it works on DBF files, but it may be worth looking at (or
encapsulating the intelligence in some object).

Bart G

 
 
 

recreation of DBF indexes

Post by Tom Gouldin » Thu, 01 May 1997 04:00:00



> Hi,

> I've found how to create/delete indexes at run-time, but I've a
> problem with the MDX file.

> The file is automatically created (if not already there) when I
> create
> the first index, and automatically removed when I remove the last
> index. That's fine.

> But if I remove (the end user will do that for sure) the MDX from
> disk
> while there are still indexes than Delphi refuse to open the table.

> Is there a why (with VCL, no calls to BDE please) to say: ok, forget

> about any indexes and files and start again from scratch ?

>         Thanks, Luca.

 I believe that the DBF-MDX format stores a bit in the DBF header that
basically says an MDX should be accompanying it. When you
programatically remove the MDX indexes, that bit is cleared. If you
delete the MDX from the OS, its not. If you want to hack the DBF file on
a binary basis, you can reset it. (Not much fun, huh?)

I've always found this to be the biggest drawback to the MDX format,. If
this is a big headache for you, you might consider using a different
index format. Successware has Apollo which I've heard good things
about... I've also heard that D3 has native support for FoxPro
indexes...

 
 
 

recreation of DBF indexes

Post by Roland Boucherea » Fri, 02 May 1997 04:00:00



Quote:> Is there a why (with VCL, no calls to BDE please) to say: ok, forget
> about any indexes and files and start again from scratch ?

You can let the user control this by just including the DBImpReq unit in
your project.

--
Roland Bouchereau

 
 
 

recreation of DBF indexes

Post by Roland Boucherea » Sat, 03 May 1997 04:00:00





> > Is there a why (with VCL, no calls to BDE please) to say: ok, forget
> > about any indexes and files and start again from scratch ?

> You can let the user control this by just including the DBImpReq unit in
> your project.

> --
> Roland Bouchereau

Sorry, that's the DBInpReq unit with an 'n'.

--
Roland Bouchereau

 
 
 

recreation of DBF indexes

Post by Damon Pug » Tue, 06 May 1997 04:00:00



> Hi,

> I've found how to create/delete indexes at run-time, but I've a
> problem with the MDX file.

> The file is automatically created (if not already there) when I create
> the first index, and automatically removed when I remove the last
> index. That's fine.

> But if I remove (the end user will do that for sure) the MDX from disk
> while there are still indexes than Delphi refuse to open the table.

> Is there a why (with VCL, no calls to BDE please) to say: ok, forget
> about any indexes and files and start again from scratch ?

>         Thanks, Luca.

Luca,

Here's how to programmatically clear the "has production index" flag
from your .DBF header.

Use caution - this routine will alter any file you pass it as long as it
has a .dbf extension - you will have to confirm that it is really a
dbase table prior to calling this.

--
Damon Pugh
Vision Software
http://www.vsnsoft.com

procedure DropProductionIndex(Name:String);  
{Name parameter is filename without extension}
var
  f: file of byte;
  b: byte;
  position:integer;
  mdxName:String;

begin

  {I+}  {Handle I/O errors as Exceptions}

  try
    {The 28th byte of a dBase V header controls whether
    the table has a production index or not.  We can use
    low-level file i/o to set this byte to 0.  This byte
    gets set back to 1 when an index gets created, so we
    don't have to worry about reactivating the production
    index.}

    b:=0;

    assignFile(f,Name+'.dbf');
    FileMode:=of_Write+of_Share_Exclusive;
    reset(f);
    seek(f, 28);
    write(f, b);
    closefile(f);

    {Now, delete the .MDX file}
    {$IFDEF Win32}
    if FileExists(Name+'.mdx') then DeleteFile(PChar(Name+'.mdx'));
    {$ELSE}
    if FileExists(Name+'.mdx') then DeleteFile(Name+'.mdx');
    {$ENDIF}

  except
    raise EDataBaseError.Create(
    'Could not delete index '+name+'.mdx.  File may be in use.  Make
sure all users are out of system and retry'
    );
  end;
end;

 
 
 

1. Index recreation takes long time

Hi,

I have a table with 480 million rows and size of 70GB.
I started the dbcc reindex (table_name,'') to rebuild all
indexes (4) each having 1 column........
It is running since last 25 hrs and using 98% cpu.....
is it looks normal with this big size of table......
is dropping the indexes and recreate again using create
index command will be fast than dbreindex......
what is difference between running dbcc reindex .....and
drop index then create index command?????
This is on test machine , we normally use dbcc indexdefrag
on prod machine????

Thanks
--Harvinder

2. WANTED: DBA in Informix - Willing to Travel

3. newbie index recreation question

4. FILEMAKER PRO 5 - SALE

5. VFP question - Index ReCreation and Persistent Relations

6. Looking for multi-platform, multi-dbms reporting

7. BULK INSERT requires index recreation ?

8. VB 4.0 and Informix?

9. DBF DBF DBF

10. db recreation via veritas

11. DBSNMP database user schema recreation

12. dbf index's

13. Newbie Question - DBF index problem