Share via


Visual FoxPro Data and Field Types

All data in Visual FoxPro have a particular data type, which defines values permitted for the data and the range and size of those values. After you identify and specify the data type you are using, Visual FoxPro can efficiently store and manipulate the data.

When you create a table, you can specify the type of data to store in each field of the table. You can specify more data types for fields in a table than for variables and arrays. Variables and arrays can store only a subset of the available Visual FoxPro data types; however. The value you store in a variable or array element determines the type of data in the variable or array element. For more information, see How to: Choose Data Types.

Tip

You can use the TYPE( ) function to determine the type of data stored in a variable, array element, or field.

Visual FoxPro Data Types

Data type

Description

Size

Range

Blob

Binary data of indeterminate length.

Blob values are in a memo (.fpt) file.

No code page translation is performed on Blob data.

4 bytes in a table

Limited by available memory and/or 2GB file size limit.

Character

Alphanumeric text

For example, a customer address

1 byte per character to 254

Any characters

Currency

Monetary amounts

For example, the price of an item

8 bytes

- $922337203685477.5807 to $922337203685477.5807

Date

Chronological data consisting of month, day, and year

For example, an order date

8 bytes

When using strict date formats, {^0001-01-01}, January 1st, 1 A.D to {^9999-12-31}, December 31st, 9999 A.D.

DateTime

Chronological data consisting of month, day, year, hours, minutes, and seconds

For example, date and time of arrival

8 bytes

When using strict date formats, {^0001-01-01}, January 1st, 1 A.D to {^9999-12-31}, December 31st, 9999 A.D., plus 00:00:00 a.m. to 11:59:59 p.m.

Logical

Boolean value of True or False

For example, whether or not an order has been filled

1 byte

True (.T.) or False (.F.)

Numeric

Integers or decimal numbers

For example, the quantity of items ordered

8 bytes in memory; 1 to 20 bytes in table

- .9999999999E+19 to .9999999999E+20

Varbinary

Binary values.

Varbinary data is similar to Varchar data in that values do not include padding with zero (0) bytes. The length of the contained value is stored internally.

No code page translation is performed on Varbinary data.

1 byte per hexadecimal value up to 255 total bytes

Any hexadecimal value

Variant

Variant data can be any of the Visual FoxPro data types and the null value.

Once a value is stored to a variant, the variant assumes the data type of the data it contains.

Variants are designated with an e prefix in language syntax.

See other data types.

See other data types.

In addition, Visual FoxPro provides data types that apply only to fields in tables.

Visual FoxPro Field Types

Field type

Description

Size

Range

Character (Binary)

Any Character data that you do not want translated across code pages

For example, user passwords stored in a table and used in different countries or regions.

1 byte per character to 254

Any characters

Double

A double-precision floating-point number

For example, scientific data requiring a high degree of precision.

8 bytes

+/-4.94065645841247E-324 to +/-8.9884656743115E307

Float

Same as Numeric

8 bytes in memory; 1 to 20 bytes in table

- .9999999999E+19 to .9999999999E+20

General

Reference to an OLE object

For example, a Microsoft Excel worksheet.

4 bytes in table

Limited by available memory.

Integer

Numeric value with no decimals

For example, a line number in an order.

4 bytes

-2147483647 to 2147483647

Integer (Autoinc)

Same as Integer but also an automatically incrementing value. Read-only.

4 bytes

Value controlled by autoincrement Next and Step values.

Memo

Alphanumeric text of indeterminate length or reference to a block of data

For example, notes about a phone call in a phone log.

4 bytes in table

Limited by available memory.

Memo (Binary)

Same as Memo except that memo field data does not change across code pages

For example, a login script used in different countries or regions.

4 bytes in table

Limited by available memory.

Varchar

Alphanumeric text.

Varchar is similar to Character except values in Varchar fields do not include padding with additional spaces. The length of the contained value is stored internally.

1 byte per character up to 254 total bytes

Any characters

Varchar (Binary)

Varchar type data that you do not want translated across code pages.

1 byte per character up to 254 total bytes

Any characters

Each data type has its own characteristics, including storage size:

Data Type Storage Differences

FoxPro Character Date Integer

To see a list of the functions you can use with each data type, see Language Categories.

See Also

Other Resources

Data and Field Types