xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

CREATE

Creates and opens an empty structure extended database file.

Syntax

CREATE <cDatabaseExt>

Arguments

<cDatabaseExt>
This is the name of the database file to create. It can include path and file extension. When no path is given, the file is created in the current directory. The default file extension is DBF. <cDatabaseExt> can be specified as a literal file name or as a character expression enclosed in parentheses.

Description

The CREATE command creates a new database file and opens it exclusively in the current work area. The database has the following pre-defined field names and database structure:

Fields in a structure extended file
PositionField nameTypeLengthDecimals
1FIELD_NAMECharacter100
2FIELD_TYPECharacter10
3FIELD_LENNumeric30
4FIELD_DECNumeric40

A database of this structure is called "structure extended" since it stores structural information of a databse in its records. The CREATE FROM database command can then be used to create a database file of this structure programmatically.

Note:  The length of a field of type Character is calculated as the sum of FIELD_LEN plus 256 * FIELD_DEC. The maximum length, however, is limited to 64k. Use a MEMO field to store longer Character strings.

Info

See also:COPY STRUCTURE EXTENDED, CREATE FROM, DbCopyStruct(), DbCopyExtStruct(), DbCreate(), DbStruct()
Category: Database commands
Source:rtl\dbstrux.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates how to create a database file programmatically
// using a structure extended file.

   PROCEDURE Main
      CREATE Temp
      APPEND BLANK

      REPLACE FIELD_NAME WITH "Lastname" , ;
              FIELD_TYPE WITH "C" , ;
              FIELD_LEN  WITH 25  , ;
              FIELD_DEC  WITH 0
      CLOSE Temp

      CREATE Address FROM Temp
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe