高分请教Paradox几个问题!紧急求救(200分)

  • 主题发起人 Joy_Wang
  • 开始时间
J

Joy_Wang

Unregistered / Unconfirmed
GUEST, unregistred user!
1。请问Paradox是否与Dbase一样,在delphi中的delete只是软删除,
并没有将记录真正删除?
2。请问如果是软删除的话,该使用BDE的那个函数来进行硬删除?DbiPackTable这个
函数是不是还可以用?
 
Paradox将记录真正删除,因此删除前要确认此项操作,如要软删除需编程。
 
但删除后空间并没有回收,需用pack将其空间回收。
如果说是Paradox将记录真正删除的话,有点解释不过吧!
我的文件本来有1563K,delete删除居然大小不变。
 
应该是将纪录删除了, 具体想知道某个文件的大小, 需要点属性看具体的字节数! 有可能
你删除纪录后占用的空间不会变!
 
呵呵,既然我问了,当然是刷新了,然后再点击看属性,请相信我还没粗心到哪个地步,
事实确实在程序中使用delete后,数据库文件大小不变!!!
 
paradox数据是真删除,但会存在"空洞",需用pack将其空间回收。
 
真正的删除
 
paradox数据刚删除,还保留一些信息,但加入新纪录后,有信息被覆盖,这和dbf库的软删除
是不同的。
 
如果是其他数据库一般也不缩小,为了性能,它的空间还留着,再写入的时候用这些空间。
如果是Paradox or dBASE使用是物理删除。

//Delphi中的BDE的帮助中的示例
procedure PackTable(Table: TTable);
var
Props: CURProps;
hDb: hDBIDb;
TableDesc: CRTblDesc;
begin
// Make sure the table is open exclusively so we can get the db handle...
if not Table.Active then
raise EDatabaseError.Create('Table must be opened to pack');
if not Table.Exclusive then

raise EDatabaseError.Create('Table must be opened exclusively to pack');

// Get the table properties to determine table type...
Check(DbiGetCursorProps(Table.Handle, Props));

// If the table is a Paradox table, you must call DbiDoRestructure...
if Props.szTableType = szPARADOX then begin
// Blank out the structure...
FillChar(TableDesc, sizeof(TableDesc), 0);
// Get the database handle from the table's cursor handle...

Check(DbiGetObjFromObj(hDBIObj(Table.Handle), objDATABASE, hDBIObj(hDb)));
// Put the table name in the table descriptor...
StrPCopy(TableDesc.szTblName, Table.TableName);
// Put the table type in the table descriptor...
StrPCopy(TableDesc.szTblType, Props.szTableType);
// Set the Pack option in the table descriptor to TRUE...
TableDesc.bPack := True;
// Close the table so the restructure can complete...
Table.Close;
// Call DbiDoRestructure...

Check(DbiDoRestructure(hDb, 1, @TableDesc,
nil, nil, nil, False));
end
else
// If the table is a dBASE table, simply call DbiPackTable...
if (Props.szTableType = szDBASE) then
Check(DbiPackTable(Table.DBHandle, Table.Handle, nil, szDBASE, True))
else
// Pack only works on PAradox or dBASE; nothing else...
raise EDatabaseError.Create('Table must be either of Paradox or dBASE ' +

'type to pack');

Table.Open;

end;
 
估计paradox 跟 Access 类似;
使用SQL语句来删除就行了!
adods.delete的话,是软删除;

如果测试无错误的话,建议结束问题!
 
顶部