次の方法で共有


How to: Choose Data Types

After you specify the name for a field, you can choose the type of data that the field can store.

To chose a data type for a field

  1. Open the table in the Table Designer.

  2. On the Fields tab, select the field that you want.

  3. In the Type list, select a data type for the field.

    Tip

    If the field has a Numeric or Float type, set the number of decimal places in the Decimal column. If an integer field contains automatically incrementing values, you need to specify next and step values. For more information, see How to: Set Autoincrementing Field Values.

For more information, see Fields Tab, Table Designer.

To choose a data type for a field programmatically

  • When creating the table using the SQL CREATE TABLE command, specify the data type for the field.

-OR-

  • To edit an existing table, open the table with the USE command and then use the SQL ALTER TABLE command.

For more information, see CREATE TABLE - SQL Command or ALTER TABLE - SQL Command.

For example, the following code creates and opens a table named Customer with three fields, Cust_ID, Company, and Contact using the CREATE TABLE command:

CREATE TABLE Customer (Cust_ID C(6), Company C(40), Contact C(30))

In the example, C(6) indicates the field contains Character data and has a field width of 6 characters.

See Also

Tasks

How to: Edit Table Structure

How to: Add Indexes to Fields

Concepts

Field Creation

Other Resources

Working with Fields

Working with Tables (Visual FoxPro)