These commands show you the contents of the current database, listing all tables and views, their fields, indexes, relations, and other properties, but not stored procedures.
DISPLAY | LIST DATABASE
[ TO PRINTER [ PROMPT ]
| TO [ FILE ] cFileName [ ADDITIVE ] ]
[ NOCONSOLE ]
Most of the information shown in the listing is available from either ADBOBJECTS()
or DBGetProp()
. However, the index information can only be extracted by opening the individual tables and using the TAG()
, KEY()
and other index functions.
This means there's one case where you'll want to parse the output of LIST DATABASE
—when a table is trashed and you can't open it to find index information. Even then, it doesn't give you everything you need, just the tag name and whether or not it's a candidate key. A better solution is to use the GENDBC utility provided with Visual FoxPro in the first place—it creates a program which, when run, re-creates your database. We recommend you make a habit of running it against a database every time you change its structure. Call it insurance. (Be forewarned: In VFP 3 and VFP 5, we know of at least one case where GENDBC can't provide you a perfect replica. Adding a FOR condition to a primary key is reasonably complex and GENDBC doesn't handle it right.)
These commands are fairly forgiving. If you issue them without an OPEN DATABASE
, you're prompted to choose one.
In VFP 3, the query that produces a view sometimes gets cut off in the listing produced by this command. You can see the problem by opening the TasTrade sample database and issuing DISPLAY DATABASE
. Then, check the *SQL lines for the views. The problem appears to be fixed in later versions.
OPEN DATA TasTrade
LIST DATABASE TO DATLIST.OUT NOCONSOLE
MODI COMM DATLIST.Out && leave wordwrap off
ERASE DATLIST.Out
ADBObjects(), Candidate(), DBGetProp(), Descending(), Display and List, For(), Key(), Primary(), Relation(), Tag(), Target()