CREATE CURSOR test (f1 c(2),f2 c(8),f3 C(6),f4 c(7),f5 c(2),f6 c(3))
*随机产生2W条记录用于测试
FOR i=1 TO 20000
INSERT INTO test VALUES (transform(INT(RAND(-1)*10)),transform(INT(RAND(-1)*10)),transform(INT(RAND(-1)*10)),;
transform(INT(RAND(-1)*10)),"","")
ENDFOR
CLEAR
?"测试结果"
s1=SECONDS()
AFIELDS(af)
FOR i=1 TO ALEN(af,1)
UPDATE test SET &af(i,1)="0" WHERE EMPTY(&af(i,1))
ENDFOR
?"
UPDATE语句耗时:",SECONDS()-s1
UPDATE test SET f5="",f6=""
s1=SECONDS()
FOR nIndex = 1 TO FCOUNT()
cField = FIELD(nIndex)
REPLACE ALL (cField) WITH "0" FOR EMPTY(EVALUATE(cField))
NEXT
?"
replace语句耗时:",SECONDS()-s1
UPDATE test SET f5="",f6=""
s1=SECONDS()
SCAN ALL
FOR nIndex = 1 TO FCOUNT()
cField = FIELD(nIndex)
IF EMPTY(EVALUATE(cField))
REPLACE (cField) WITH "0"
ENDIF
NEXT
ENDSCAN
?"SCAN内replace耗时:",SECONDS()-s1
[
本帖最后由 xmlz 于 2011-6-26 14:49 编辑 ]