VFP基础教程 2.8 使用命令建立和操作索引文件

一。建立索引文件:对打开的索引文件,可用下列命令建立索引:

格式:index on 索引关键字|tag 索引名|to 索引文件名

说明:(1).tag 索引名:指定索引名,此索引存放在与表名相同的。cdx文件中。

(2).to 索引文件名:选择此项生成独立索引,即一个索引存放在一个索引文件中;否则生成的是结构化复合索引。

例1:建立"工资情况"表的结构化复合索引文件,其索引关键字分别为姓名和工资,而索引名分别为xm和gz.

use 工资情况
browse
index on 姓名 tag xm
index on 工资 tag gz
browse

分别执行以上命令后,生成了"工资情况。cdx"文件,其中存放了xm和gz两个索引。

例2:用"姓名"作索引关键字,建立"职工档案。dbf"的独立索引文件,文件名为a.idx.

use 职工档案
index on 姓名 to hello &&执行此命令,检查默认目录e:myvfp,会发现多了一个文件:hello.idx
use

二。打开索引:打开表时,系统会自动打开结构化复合索引,但此时显示的仍是物理顺序。要使索引起作用,必须指定主控索引。主控索引就是控制当前显示顺序的索引。也可以在打开表的同时指定主控索引。

1.打开表的同时打开索引并指定主控索引:

格式:use 表名 [index 索引文件名] [order tag 顺序号|索引名]

说明:(1).index 索引文件名:用于打开独立索引文件。

(2).order tag 顺序号|索引名:用于打开结构化复合索引。其中,顺序号为该索引在复合索引文件中的先后顺序,即在"表设计器"的"索引"选项卡中看到的该索引的位置。

http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155129_7494.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155113_8680.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706160204_8207.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155910_4768.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155034_6732.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706154830_3411.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706160108_7512.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155449_4718.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155942_7780.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706160223_2073.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706154807_0899.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706160319_2347.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155303_8937.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155603_0621.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155655_2814.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155351_2938.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155727_5384.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706160125_7534.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155013_7862.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155206_4656.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155410_6232.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155835_8071.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706160026_5485.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706160243_8073.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155524_4240.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706160048_6915.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706154756_7784.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155053_7673.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706155621_0640.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706154917_5854.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706160004_9690.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706160428_1142.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706154935_6600.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706160336_2840.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706154853_1713.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706154954_7359.html
http://www.qingdaqiye.com/kindeditor/attached/file/20200706/20200706160146_7895.html

    原文作者:hahaer218
    原文地址: https://blog.csdn.net/hahaer218/article/details/107191947
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞