VFP 中的难点 一、索引的总结
类别 单索引 (idx) 举例 Use yyy Index on to xm1.idx Index on 性别 to xb1 Index on 部门 部门+dtoc(出生日期 to bm1 出生日期,1) 出生日期 结 构 复 合 Use yyy 新建 索引 (cdx) Index on tag xm Index on 性别 tag xb
非 结 构 复 Use yyy 合索引 (cdx) Index on tag xm2 of fjg Index on 性别 tag xb2 of fjg
结 构 复 合 随表一同打开或关闭 索引 单索引 Use yyy index xm1,xb1 或 use yyy 打开 Set index to xm1,xb1 非 结 构 复 Use yyy index fjg 合索引 或 use yyy Set index to fjg Set order to 0/1/2 | xm2,xb2
单 索 引 / 非 Close index 结构复合 关闭 索引 结 构 复 合 与表一同关闭或打开 索引 数 据 改 打的索引 动 单 索 引 → use yyy index xm1,xb1 复合索引 (xm1.idx,xb1.idx 两个素引文件 reindex
copy index xm1,xb1**结构复合索引 结构复合索引 copy index xm1,xb1 to fjg**非结构复合索引 非结构复合索引
索引文 件之间 的转换
复 合 索 引 set index to fjg →单索引
**打开非结构复合索引文件 如果是结构 打开非结构复合索引文件/如果是结构 打开非结构复合索引文件
复合索引文件已经随表打开了 modi stru copy tag xm2 to xm3.idx copy tag xb2 to xb3.idx
review(素引、排序等) 素引、排序等 素引
删除记录
use 课程表 brow pack brow
物理排序
sort on 考试类型/d,课程代号/a to kcb sele j ?sele() use kcb brow sele 1
素引 单素引
index on 考试类型 to kslx brow set order to kslx set order to 1 brow close index brow sele 1
index on 考试类型 to kslx brow close index brow set index on set index to kslx brow close index
结构素引
index on 考试类型 tag ks index on 课程代号 tag kc dir *.cdx close index
非结构素引
index on 考试类型 tag ks of fjg index on
课程代号 tag kc of fjg set index to fjg set order to kc brow set order to ks brow dele tag kc of fjg close index set index to
go 7 go 1 brow
物理查找
locate for 课程名称="算法设计" ?recno() ?found() disp continue ?found() ?eof()
素引查找
index on 课程名称 tag kcmc set order to kcmc seek "算法
设计" ?found() clear ?found() disp continue() ?eof() brow seek 成绩=68 seek 68
brow kcmc index on 学时数 tag xss seek 68 ?found() disp find 68 disp go 1 find 68 brow 统计计算
计数
count to xx ?xx brow count to xx for 考试类型="考试" ?xx
求和
sum to x1 fields 学时数 sum 学时数 to x1
求平均值
average 学时数 to x2 for 考试类型="考试" calculate sum(学时数),avg(学时数),max(学时数);
min(学时数) to x1,x2,x3 calculate sum(学时数),avg(学时数),max(学时数); ,min(学时数) to x1,x2,x3,x4 brow
分类汇总
index on 考试类型 tag lx set order to lx total on 考试类型 to y1 fields 学时数 use y1 brow close all clear
多表临时性关联
sele 2(先设子表) (先设子表) use clkc 第1步 index on 材料代码 tag dm set order to
dm sele 4 第2步 use clls(clls 为主表) 第 3 步 set relation to 材料代码 into clkc(当前在哪一个工作区) (当前在哪一个工作区) 第 4 步 set skip to clkc(建立一对多的关联) (建立一对多的关联) sele 4 查看 brow
多 表 临 时 性 关 联
sele 2 brow
sele 2 dir use clkc index on 材料代码 tag dm set order to dm sele 4 use clls set relation to 材料代码 into clkc go 4 brow sele 2 brow sele 4 set skip to clkc go 4 brow set skip to set relation to close all open data 110
creat 110 creat data 110 modi data OPEN DATABASE d:\vfp\学生实验原始表\x10.dbc SHARED MODIFY DATABASE USE d:\vfp\学生实验原始表\clls.dbf IN 0 SHARED SELECT 2 SELECT 1 SELECT 2 SET ORDER TO TAG Dd OF d:\vfp\学生实验原始表\clkc.cdx IN Clkc SET RELATION TO Clls.材料代码 INTO Clkc ADDITIVE USE d:\
vfp\学生实验原始表\clkc.dbf IN 0 AGAIN ALIAS Clkc_a SHARED USE d:\vfp\学生实验原始表\x4.dbf IN 0 SHARED SELECT 4 BROWSE LAST SET ORDER TO TAG Dm OF d:\vfp\学生实验原始表\clls.cdx IN Clls S