You are on page 1of 2

DISPLAY Command Example

The following example opens the customer table in the testdata database. The
contents of the first record are displayed.

CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE customer && Opens Customer table
CLEAR
DISPLAY FIELD cust_id, company, contact OFF NEXT 10

DELETE DATABASE Command Example

This example creates a database named people. A table named friends is created and is
automatically added to the database. DISPLAY TABLES is used to display the tables in the
database, and DISPLAY DATABASES is used to display information about the tables in the
database.

DELETE DATABASE is used with the DELETETABLES option to remove the database and
its friends table from disk.

CLOSE ALL
CREATE DATABASE people
CREATE TABLE friends (FirstName C(20), LastName C(20))
CLEAR
DISPLAY TABLES && Displays tables in the database
DISPLAY DATABASES && Displays table information
CLOSE ALL
DELETE DATABASE people DELETETABLES

CREATE DATABASE Command Example

This example creates a database named people. A table named friends is created and is
automatically added to the database. DISPLAY TABLES is used to display the tables in the
database, and DISPLAY DATABASES is used to display information about the tables in the
database.

CREATE DATABASE people


CREATE TABLE friends (FirstName C(20), LastName C(20))
CLEAR
DISPLAY TABLES && Displays tables in the database

DISPLAY DATABASES && Displays table information


COPY STRUCTURE Command Example

In the following example, the customer table is opened, its structure is copied to a table called
backup and backup is opened. APPEND FROM then appends records to the backup table
from the customer table, and a Browse window is opened for the backup table.

CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE customer && Opens Customer table

COPY STRUCTURE TO backup


USE backup
APPEND FROM customer FOR country = 'UK'
BROWSE FIELDS contact, country

APPEND FROM Command Example

In the following example, the customer table is opened, its structure is copied to a table called
backup, and backup is then opened. Visual FoxPro then appends all records from Finland
from the customer table. These records are then copied to a new delimited file called
TEMP.TXT.

CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE customer && Open customer table
COPY STRUCTURE TO backup
USE backup
APPEND FROM customer FOR country = 'Finland'
COPY TO temp TYPE DELIMITED
MODIFY FILE temp.txt
USE
DELETE FILE backup.dbf
DELETE FILE temp.txt

CALCULATE Command Example

CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'data\testdata')
USE orders && Open Orders table
SET TALK ON
CLEAR
CALCULATE AVG(order_amt), MIN(order_amt), MAX(order_amt)
CALCULATE STD(order_amt), VAR(order_amt) TO gnStd, gnVar