Compartir a través de


How to: Add Fields to Tables

When opening the table in the Table Designer, the Fields tab displays a row for the first field and adds a field following the field as you define it. You can add additional fields to the table in the order that you want.

To add a field to a table

  1. Open the table in the Table Designer.

  2. On the Fields tab, insert the cursor in the field that follows the one you want to add.

  3. Click Insert.

    A new field appears preceding the selected field with a default field name, type, and width.

  4. Change the attributes for the field to the ones you want.

  5. When you are finished, click OK.

    Visual FoxPro prompts you to confirm changes to table structure.

  6. To confirm the table structure changes, click Yes.

To add a field to a table programmatically

  • Use the SQL ALTER TABLE command and include the ADD COLUMN clause.

For more information, see ALTER TABLE - SQL Command.

For example, the following code adds a field named Fax with Character type and a field width of 10 characters to a customer table:

ALTER TABLE Customer ADD COLUMN Fax C(20) 

See Also

Tasks

How to: Edit Table Structure

How to: Name Fields

Concepts

Field Creation

Other Resources

Working with Fields

Working with Tables (Visual FoxPro)