These commands create and destroy databases, respectively. A database is a collection of tables, views, connections and other stuff. See "DBC, DBF, FPT, CDX—Hike!" for more on what constitutes a database in Visual FoxPro.
CREATE DATABASE [ Name | ? ]If you omit Name, whether or not you include the "?", the Open dialog appears with a default name of DATAn.DBC, where n is the number of times you've used the Open dialog to name a new database in this session. It doesn't matter whether or not you assign a name other than the default. If you use the Open dialog, the counter on the end goes up. Try this:
CREATE DATABASE ?
* Change the name to Fred and choose OK
CREATE DATABASE ?
* Note that new database name offered is DATA2.DBCWeird, but it doesn't really matter, since you'd never want to use the default name.
Creating a database opens it (exclusively). Unlike tables, databases don't use anything like work areas, so opening one doesn't close any others that are already open. However, only one database can be current at a time. The newly created database is empty and becomes the current database. You have to use commands or the Database Designer to put stuff in it.
When a database is open and current, creating a new table automatically puts it in the OPEN DATABASE.
Be careful about database names. Because the database is stored as a file, you get only as many characters as the Windows version allows. Using VFP 3 in Windows 3.1, you can CREATE DATABASE AVeryLongName, but it's stored as AVeryLon.DBC.
CREATE DATABASE MyImportantDataDELETE DATABASE Name | ? [ DELETETABLES ] [ RECYCLE ]DELETE DATABASE is the right way to get rid of a database. It does all the necessary cleanup, including freeing all the tables in the database. Deleting the DBC, DCT and DCX files any other way orphans the tables in the database, which leaves them unusable until you issue the FREE TABLE command.
Unlike CREATE DATABASE, you must specify either a name or the ? with DELETE DATABASE. The ? brings up the Open dialog to choose a database to delete, bizarre as that sounds. (In fact, despite its title, the Open dialog is the one that has the right functionality.)
Specifying DELETETABLES means that Visual FoxPro should delete all the tables in the database along with the database itself. This is pretty drastic, but can be handy when working with test data.
Add the RECYCLE keyword to send the database files to the purgatory of the Windows Recycle Bin. Without it, they're gone, gone, gone.
A database must be closed in order to delete it.
DELETE DATABASE respects the setting of SAFETY.
Add Table, Close Database, Create, Create SQL View, Create Table, DBGetProp(), DBSetProp(), Modify Database, Open Database, Pack Database, Set Database, Set Safety, Validate Database
