Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Repair & Optimize All Tables in EDBManager
Mon, Oct 12 2009 2:12 AMPermanent Link

Charalampos Michael
Dear Tim,
  Please add a "Repair" and "Optimize" All Tables function in EDBManager

Thank you
Mon, Oct 12 2009 2:11 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< Please add a "Repair" and "Optimize" All Tables function in EDBManager >>

Noted.  I'll probably implement this as part of the multi-select
functionality, that way you can select all or just some of the tables and
then choose each operation as needed.

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Oct 12 2009 3:05 PMPermanent Link

Charalampos Michael
Dear Tim,

> Noted.  I'll probably implement this as part of the multi-select
> functionality, that way you can select all or just some of the tables and
> then choose each operation as needed.

It will be nice to put it when right click "Tables" too!
Also a small report will be nice too. (as dbisam)

--
Charalampos Michael - [Creation Power] - http://www.creationpower.gr
Mon, Oct 12 2009 4:15 PMPermanent Link

"Daniel Kram"
I wrote something you can certainly use (see below.) My code is written to
work with MySQL/ElevateDB/Access/SQL Server/DB2, so if you see casting, or
other weird variables, you can probably elliminate many/most and just use
Elevate.

I added Repair/RepairAll, Optimize and OptimizeAll

You will have to create the qryWork object or replace with your own. Mine is
created as a TDataSet and I cast it as Elevate or ADO or whatever I need in
a generic function.

Let me know if you have any questions.

// ----------------------------------------------------------------------------

function RepairAllTables: boolean;
{
 Attempt to repair all tables
}
var
 sSQL:    string;
 nCount:  integer;
 lstWork: TStringList;
begin
 { retrieve all table names and iterate through each table }
 sSQL := 'SELECT Name FROM Information.Tables';
 qryWork.Active := False;
 qryWork.Sql.Clear;
 qryWork.Add(sSQL);
 qryWork.Active := True;
 lstWork := TStringList.Create;
 try
   while (not qryWork.Eof) do
   begin
     lstWork.Add(qryWork.FieldByName('Name').AsString);
     qryWork.Next;
   end;
   for nCount := 0 to lstWork.Count - 1 do
   begin
     Result := RepairTable(lstWork.Strings[nCount]);
     if (not Result) then exit;
   end;
 finally
   qryWork.Active := False;
   lstWork.Free;
 end;
end;

// ----------------------------------------------------------------------------

function RepairTable(p_sTableName: string): boolean;
{
 Attempt to repair a table
}
var
 sSQL: string;
begin
 try
   Result := True;
   if (p_sTableName = '') then exit;

 sSQL := 'REPAIR TABLE "' + p_sTableName + '"';
 qryWork.Active := False;
 qryWork.Sql.Clear;
 qryWork.Add(sSQL);
 qryWork.Active := True;
 finally
   qryWork.Active := False;
 end;
end;


// ----------------------------------------------------------------------------

function OptimizeAllTables: boolean;
{
 Attempt to optimize all tables
}
var
 sSQL:    string;
 nCount:  integer;
 lstWork: TStringList;
begin
 { retrieve all table names and iterate through each table }
   sSQL := 'SELECT Name FROM Information.Tables';
 qryWork.Active := False;
 qryWork.Sql.Clear;
 qryWork.Add(sSQL);
 qryWork.Active := True;
 lstWork := TStringList.Create;
 try
   while (not qryWork.Eof) do
   begin
     lstWork.Add(qryWork.FieldByName('Name').AsString);
     qryWork.Next;
   end;
   for nCount := 0 to lstWork.Count - 1 do
   begin
     Result := OptimizeTable(lstWork.Strings[nCount],'');
     if (not Result) then exit;
   end;
 finally
   qryWork.Active := False;
   lstWork.Free;
 end;
end;

// ----------------------------------------------------------------------------

function OptimizeTable(p_sTableName: string;
                             p_sIndexName: string = ''): boolean;
{
 Attempt to optimize a table
}
var
 sIndex,
 sSQL:   string;
begin
 try
   Result := True;
   if (p_sTableName = '') then exit;
     if (p_sIndexName = '') then
       sIndex := ''
     else
       sIndex := ' USING "' + p_sIndexName + '"';

     sSQL := 'OPTIMIZE TABLE "' + p_sTableName + '"'
              + sIndex
              ;
 qryWork.Active := False;
 qryWork.Sql.Clear;
 qryWork.Add(sSQL);
 qryWork.Active := True;
 finally
   qryWork.Active := False;
 end;
end;


Daniel
Tue, Oct 13 2009 2:50 AMPermanent Link

Uli Becker
Tim,

> Noted.  I'll probably implement this as part of the multi-select
> functionality, that way you can select all or just some of the tables and
> then choose each operation as needed.

Thanks. That would be a good feature.

In addition: after repairing a table in DBISAM there was a report with
some details so that one could see at least if the table had been
corrupted or not. With EDB this report doesn't seem to exist any more.
How about "reactivating" it?

Uli
Tue, Oct 13 2009 12:30 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< In addition: after repairing a table in DBISAM there was a report with
some details so that one could see at least if the table had been corrupted
or not. With EDB this report doesn't seem to exist any more. How about
"reactivating" it? >>

The way that the repair works in EDB is a bit different.  As long as it can
get a decent read on the source table, then it can repair the table okay.
DBISAM performed a repair in-place, so it was a little pickier about how the
source table had to look.

However, yes, there are plans to add more information about the state of a
table, along with a VERIFY TABLE statement.

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Oct 13 2009 2:28 PMPermanent Link

Fons Neelen
Hi Tim,

> However, yes, there are plans to add more information about the state of a
> table, along with a VERIFY TABLE statement.

Yes!  If you mean by VERIFY a REPAIR without actually repairing it. The
added info is also welcome.

Best regards,
Fons
Tue, Oct 13 2009 5:00 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Fons,

<< Yes!  If you mean by VERIFY a REPAIR without actually repairing it. >>

Yes, that is what I mean.

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Oct 14 2009 3:08 AMPermanent Link

Uli Becker
Tim,

> The way that the repair works in EDB is a bit different.  As long as it can
> get a decent read on the source table, then it can repair the table okay.
> DBISAM performed a repair in-place, so it was a little pickier about how the
> source table had to look.

I understand. In my opinion a detailed information is not that
important. The most important thing is to know whether the table was
corrupted or not.

Uli
Thu, Oct 15 2009 2:13 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< I understand. In my opinion a detailed information is not that important.
The most important thing is to know whether the table was corrupted or not.
>>

Yes, right now this is reported for the data (rows/blobs), but not the
indexes.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image