*!*
Append 和 Select SQL 方法追加记录的速度比较:
Clear
Close Databases
Set Talk Off
*!*
1. 样本测试数据构造:9表 x 100,000记录 = 900,000条
? "正在构造样本测试数据......"
For I = 1 To 9
lcTab = "T" + Transform(I, "@L 99")
Create Cursor &lcTab. (Id I, Name C (10))
? lcTab
For J = 1 To 100000
Insert Into &lcTab. Values (J, Sys(3))
Endfor
Endfor
? "=================="
*!*
2. Append 方法,耗时 2.913 秒
T1 = Seconds( )
Create Cursor TT1 (Id I, Name C (10))
Select TT1
Append From Dbf("T01")
Append From Dbf("T02")
Append From Dbf("T03")
Append From Dbf("T04")
Append From Dbf("T05")
Append From Dbf("T06")
Append From Dbf("T07")
Append From Dbf("T08")
Append From Dbf("T09")
? "Append 方法,记录数:" + Transform(Reccount()) + ",耗时秒:" + Transform(Seconds( ) - T1)
? "=================="
*!*
3. Select SQL 方法,耗时 1.525 秒
T1 = Seconds( )
Select * From T01 ;
UNION All ;
Select * From T02 ;
UNION All ;
Select * From T03 ;
UNION All ;
Select * From T04 ;
UNION All ;
Select * From T05 ;
UNION All ;
Select * From T06 ;
UNION All ;
Select * From T07 ;
UNION All ;
Select * From T08 ;
UNION All ;
Select * From T09 ;
Into Cursor TT2
? "Select SQL 方法,记录数:" + Transform(Reccount()) + ",耗时秒:" + Transform(Seconds( ) - T1)