Microsoft KB Archive/93633

= HOWTO: How to Create or Modify a Database in an Application =

Article ID: 93633

Article Last Modified on 12/3/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft FoxPro 2.6a Standard Edition
 * Microsoft FoxPro 2.6 for MS-DOS
 * Microsoft FoxBASE+ 3.0 for MS-DOS

-



This article was previously published under Q93633



SUMMARY
In FoxPro 2.x, to create or modify a database under program control, you can use the COPY TO STRUCTURE EXTENDED, the CREATE FROM command.

In Visual FoxPro, you can use the ALTER TABLE command.

Also, you can use the CREATE TABLE command in any version of FoxPro.



MORE INFORMATION
The following code examples create a new database named TEMP that contains one field. The field is named LASTNAME and is 30 characters long.

FoxPro 2.x
USE anyfile COPY TO temp STRUCTURE EXTENDED USE temp

APPEND BLANK REPLACE field_name WITH 'lastname' REPLACE field_len WITH 30 REPLACE field_type WITH 'C'  REPLACE field_dec WITH 0 CREATE newfile FROM temp NOTE: To add more than one field to the table, perform another APPEND BLANK and then the REPLACE sequence again.

The COPY STRUCTURE EXTENDED command creates a new database file that describes the structure of the original database. Each record of the new database describes a field of the original database.

NOTE: The COPY STRUCTURE EXTENDED and CREATE FROM commands also work in stand-alone applications created with the FoxPro Distribution Kit.

Visual FoxPro
USE anyfile ALTER TABLE Temp ADD COLUMN  &quot;Lastname&quot; C(10)

CREATE TABLE Command
You can also use the CREATE TABLE command to modify or create a database. Its syntax is as follows: CREATE table ( [( [, ])[,     ...]]) The following example creates a table with the NAME, ADDR, CITY, ZIP, and SALARY fields, plus a memo field called COMMENTS: CREATE Table employee ; (name C(20), addr C(30), city C(30), zip C(5), salary N(8,2), ;        comments M)

Additional query words: VFoxWin 3.00 FoxDos FoxWin 1.00 1.x 2.00 2.10 2.50 2.50a 2.50b 2.60 2.60a dbf

Keywords: kbhowto kbcode KB93633

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.