《vfp培训内容(于)》由会员分享,可在线阅读,更多相关《vfp培训内容(于)(8页珍藏版)》请在金锄头文库上搜索。
1、一、界面简介二、创建数据库(表)(create) ,字段类型、长度、字段名三、数据库打开和关闭(use close all)、数据库浏览(browse display list)、查找(locate go)、数据库结构修改(modify structure copy structure field)、输入数据(append insert)、修改替换(replace)、删除(delete pack zap recall)、统计(count sum average)、导入导出(copy to)四、数据库的索引、排序/多字段排序(index on to sort to on)五、逻辑关系 = = a
2、nd or ()六、其它常用命令介绍Select 1/a clear set default to set exact on/off set safety on/off set exclusive on/off set talk on/off ?七、几个常用函数介绍Alltrim() ltrim() rtrim() strtran() dbf() deleted() int() round() substr() left() right() recno()八、数据库关联(工作区、别名)set relation to (未讲)九、使用 Select 语句 进行查询、统计、关联、比较等(selec
3、t distinct as from where group by having order by into)。(例:全选、部分字段、加条件、统计、多字段统计、加条件统计、人数统计升降序 desc、筛选 having、关联比较、嵌套、找出重复记录)十、如何打印数据库内容,与 EXCL 之间的格式转换(未讲)附:以下现场培训中使用的命令,供练习参考(主要的命令做了注释,详见命令后括号中内容)。use ?set defa to c:vfpdbf (设默认路径)use?use 11nlqbrowlist next 30list xm,ksbh next 30cleargo 1 (定位到第一条记录)l
4、ist xm,ksbh next 30list xm,ksbh for lqzydm=020201brow for ksbh=100180210504371browloca for ksbh=100180210504371loca for xm=王browse for xm=王 browgo 12browMODIFY STRUCTUREbrowMODIFY STRUCTUREmodi stru (修改库结构)browcopy stru field xm,ksbh,lqdwdm to 10018bdk (拷贝结构)copy field xm,ksbh,lqdwdm to 10018bdk (拷贝
5、内容)close all (关闭所有文件)clea (清空屏幕)appendbrowappend blank (追加一条空记录)browinsert (在当前记录后面插入一条空记录)browinsert before (在当前记录前面插入一条空记录)browbrow field ksbh,xm,lqzydmreplace next 8 lqzydm with 010101 (替换以下 8 条记录)replace all lqzydm with 010103 for lqzydm=080200(指定条件下替换)brow field ksbh,xm,lqzydmdelete next 1delet
6、e all for xm= packbrow field ksbh,xm,lqzydmdele all (为所有记录添加删除标记)recall all (去掉所有记录的删除标记)count for lqzydm=081000 (统计某个专业的录取人数)brow field ksbh,xm,lqzydm,zfcount for lqzydm=081000 and zf=356 (多条件统计)count for lqzydm=081000 and zf081000brow for lqzydm081000 field ksbh,xm,lqzydmclose alluse testsele 2 (转
7、到第二分区)use 10018bdksele 1sele 2clearuse 10018bdk shar (只读方式打开)brow?112?112*2sele 1browrepl all xm with allt(xm) (去掉左右空格)repl all xm with strt(xm, ,) (去掉所有空格)?dbf() (查看路径)brow for dele()browcoun for dele()brow field ksbh,xm,zfMODIFY STRUCTUREbrowbrow fiel ksbh,xm,zfrepla all zf with int(zf) (总分取整)repl
8、a all zf with round(zf,1) (四舍五入,保留 1 位小数)repla all zf with round(zf,0) (四舍五入,不保留小数)replace all ksbh with subs(ksbh,6,10) (取字段指定部分)replace all ksbh with 10018+ksbhmodi strubrowrepla all xh with recno() (数值型字段编序号)close alluse 11nlqbrowselect * from 11nlqselect ksbh,zjhm from 11nlqselect ksbh,zjhm,lqzy
9、dm,xm from 11nlq where lqzydm =020201select ksbh,zjhm,lqzydm,xm from 11nlq where lqzydm =020201 into table 020201sjsele dist lqzydm,coun(*) from a group by lqzydm(各录取专业人数统计)sele dist lqyxsm,lqzydm,coun(*) from a group by lqyxsm,lqzydm (分院系所、分专业人数统计)sele dist lqyxsm,lqzydm,coun(*) from a group by lqy
10、xsm,lqzydm where lqyxsm in (001,002,005)sele dist lqzydm,coun(*) from a group by lqzydmsele dist lqzydm,coun(*) from a group by lqzydm order by lqzydm (分专业统计并按专业排序)sele dist lqzydm,coun(*) from a group by lqzydm order by lqzydm desc (分专业统计并按专业降序排序)sele dist lqzydm,coun(*) from a group by lqzydm orde
11、r by lqzydm desc having coun(*)=10 (筛选出人数=10 的)sele dist lqzydm,coun(*) as rs from a group by lqzydm order by lqzydm desc having rs=10sele lqzydm from asele dist lqzydm from a (去掉重复记录)usesele 1sele 2use 11sbkbrowsele dist a.ksbh,b.xm,a.lqzydm from a,b where a.ksbh=b.ksbh(从 2 个数据库中关联考生编号查询)sele dist
12、a.ksbh,b.xm,b.bkzydm,a.lqzydm,a.zf from a,b where a.ksbh=b.ksbhsele dist b.* from b where b.ksbh in (sele dist a.ksbh from a)sele dist b.* from b where b.ksbh not in (sele dist a.ksbh from a) (两个数据库间比较)usesele 1sele dist ksbh from asele 1appe from 11nlq for lqzydm=020201sele dist ksbh from asele dist ksbh,coun(*) from a group by ksbhbrow cnt1brow for cnt1sele dist * from a where a.ksbh in (sele dist ksbh from a grou by ksbh having coun(*)1) (找出重复记录)sele * from a where a.ksbh in (sele dist ksbh from a grou by ksbh having coun(*)1)inde on xm to s