📄 为delphi提供pack功能.htm
字号:
<TR>
<TD vAlign=top bgColor=#ffffff>
<DIV align=center><A
href="http://www.361000.com.cn/edu/media/creatsite/cr000.htm">网站建设论坛</A>
</DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#cccc99
border=0><TBODY>
<TR>
<TD width="100%" height=84>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#cccc99
border=0>
<TBODY>
<TR>
<TD vAlign=center align=left bgColor=#eeeecc height=2>
<DIV align=center>网页设计</DIV></TD></TR>
<TR>
<TD vAlign=top width="100%" bgColor=#ffffff height=55>
<DIV align=center>
<P><A
href="http://www.361000.com.cn/edu/media/html/ht000.htm">HTML</A><BR><A
href="http://www.361000.com.cn/edu/media/css/css000.htm">CSS</A><BR><A
href="http://www.361000.com.cn/edu/media/script/sc000.htm">Script</A><BR><A
href="http://www.361000.com.cn/edu/media/dreamweaver/dr000.htm">DreamWeaver</A><BR><A
href="http://www.361000.com.cn/edu/media/flash/fl000.htm">Flash</A></P></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#cccc99
border=0><TBODY>
<TR>
<TD width="100%" height=15>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#cccc99
border=0>
<TBODY>
<TR>
<TD vAlign=center align=left bgColor=#eeeecc height=2>
<DIV align=center>美工教室</DIV></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff>
<DIV align=center><A
href="http://www.361000.com.cn/edu/media/fireworks/fi000.htm">Firworks</A><BR><A
href="http://www.361000.com.cn/edu/media/photoshop/ph000.htm">Photoshop</A><BR><A
href="http://www.361000.com.cn/edu/media/3dmax/3d000.htm">3DS
Stodio Max</A><BR><A
href="http://www.361000.com.cn/edu/media/CorelDRAW/co000.htm">CorelDraw</A></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#cccc99
border=0><TBODY>
<TR>
<TD width="100%" height=15>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#cccc99
border=0>
<TBODY>
<TR>
<TD vAlign=center align=left bgColor=#eeeecc height=2>
<DIV align=center>程序开发</DIV></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff>
<DIV align=center><A
href="http://www.361000.com.cn/edu/media/Visualbasic/vb000.htm">Visual
basic开发 </A><BR><A
href="http://www.361000.com.cn/edu/media/Delphi/de000.htm">Delphi</A><BR><A
href="http://www.361000.com.cn/edu/media/sql/da000.htm">sql</A><BR><A
href="http://www.361000.com.cn/edu/media/php/php000.htm">PHP</A><BR><A
href="http://www.361000.com.cn/edu/media/asp/asp000.htm">ASP</A><BR></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#cccc99
border=0><TBODY>
<TR>
<TD width="100%" height=15>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#cccc99
border=0>
<TBODY>
<TR>
<TD vAlign=center align=left bgColor=#eeeecc height=2>
<DIV align=center>操作系统</DIV></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff>
<DIV align=center><A
href="http://www.361000.com.cn/edu/media/Windows/wi000.htm">Windows系列</A></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#cccc99
border=0><TBODY>
<TR>
<TD width="100%" height=73>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#cccc99
border=0>
<TBODY>
<TR>
<TD vAlign=center align=left bgColor=#eeeecc height=2>
<DIV align=center>实用软件</DIV></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff height=54>
<DIV align=center><A
href="http://www.361000.com.cn/edu/media/filemange/file000.htm">管理维护
</A><BR><BR><A
href="http://www.361000.com.cn/edu/media/imagemedia/im000.htm">多媒体与图像</A>
</DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#cccc99
border=0><TBODY>
<TR>
<TD width="100%" height=15>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#cccc99
border=0>
<TBODY>
<TR>
<TD vAlign=center align=left bgColor=#eeeecc height=2>
<DIV align=center>冲浪宝典</DIV></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff>
<DIV align=center><A
href="http://www.361000.com.cn/edu/media/creatweb/cr000.htm">网络组建</A><BR><BR><A
href="http://www.361000.com.cn/edu/media/goweaver/go000.htm">入门技巧</A></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR></TD>
<TD vAlign=top height=581><BR>
<TABLE cellSpacing=0 cellPadding=0 width="96%" align=center>
<TBODY>
<TR>
<TD><!-- #BeginEditable "cont" -->
<TABLE height=544 cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD height=2><B><FONT color=#ff0000 size=5> <A
href="http://www.361000.com.cn/edu/media/Delphi/de000.htm"><IMG
height=41 src="为Delphi提供Pack功能.files/poweredbydelphi.jpg"
width=114 border=0></A></FONT></B></TD></TR>
<TR>
<TD>
<HR SIZE=1>
</TD></TR>
<TR>
<TD vAlign=top height=455>
<DIV align=center>
<P align=center><B>为Delphi提供Pack功能</B><BR></P>
<P
align=left> Delphi目前已经是国内常见的数据库编程工具,它在各方面表现不错,在支持大型多层数据库结构的同时也完全支持本地数据库。对于本地数据库中Delphi对FoxPro的支持也不错,我曾经对VB、FoxPro、Delphi的数据库操作速度进行比较,发现除了启动速度较慢外,其它各项Delphi均排在首位。而且Delphi几乎支持所有原先FoxPro所拥有的功能,对于有一定编程经验的人来说,Delphi成了编写数据库软件的一把利器,因而Delphi迅速流行起来,Delphi在我国也占有一席之地。</P>
<P
align=left> 但是我在使用Delphi编程的过程中发现它也有不如人意的地方,特别是在本地数据库dBase和Paradox方面,它居然不支持十分有用的Pack和Undelete功能。对于数据库来说,因为是一个顺序存储文件,在删除部分记录时一般采用了软删除技术,也就是说将要删除的记录标记已删除的标记,但并不立即从物理上删除这些记录(删除后库文件大小不变)。</P>
<P
align=left> 这样做可以避免仅仅删除一条记录就要将整个数据库重新写入存储器,提高了读写的效率。但是如果数据库长期不对已经被标记为删除的记录进行整理和真实删除,数据库就会越来越大,其中无用的数据所占的比率越来越大,使得数据库的读写效率迅速下降,而且造成查询速度的减慢。特别是在编写人事管理数据库应用软件时,库内要保存大量的图形文件(人员的照片),而这些数据还时常需要添加和删除,没用的数据不?quot;Pack"将占用巨大的硬盘空间,而且还将降低系统的运行速度。</P>
<P
align=left> 这是编写数据库软件的人必须考虑的一个问题。经过再三查找,我找到一些资料,解决了如何对数据库进行pack,下面是其中的核心程序的一个例子,在看例子之前,我先做一些说明:</P>
<P align=left> 1. 对于dBase和Paradox库,其Pack原理是不同的:如果是Paradox 表,
必须调用 DbiDoRestructure,重建数据库结构;如果是 dBASE 表,
只需要调用DbiPackTable。</P>
<P align=left> 2. 在做Pack删除时,必须以独占方式打开数据库时。具体请参考一下的例子。</P>
<P align=left> (为了节省篇幅,例子中只给出关键性的程序段)</P>
<P align=left> implementation<BR> uses
BDE;//做PACK必须引用次单元里的函数<BR> {$R *.DFM}<BR> procedure
TfrmPack.FormCreate(Sender:
TObject);<BR> var<BR> DBName:String;<BR> begin<BR> DBName:=ExtractFilePath(Application.ExeName);//得到数据库的位置
<BR> {设置Table}<BR> tblDBASE.DatabaseName:=DBName;<BR> tblParadox.DatabaseName:=DBName;<BR> tblDBASE.TableName:='dbsTest.dbf';<BR> tblParadox.TableName:='pdxTest.db';<BR> tblDBASE.Active:=True;<BR> tblParadox.Active:=True;<BR> end;<BR> {物理删除数据库记录Pack
a Paradox or dBASE table}<BR> // The table must be opened
execlusively before calling this
procedure...<BR> procedure TFrmPack.PackTable(FTable:
TTable);<BR> var<BR> Props:
CURProps;<BR> hDb: hDBIDb;<BR> TableDesc:
CRTblDesc;<BR> begin<BR> FTable.Active :=
False;<BR> {当数据獯蚩
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -