| xHarbour Reference Documentation > Command Reference |
![]() |
![]() |
![]() |
Creates and opens an empty structure extended database file.
CREATE <cDatabaseExt>
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
| Position | Field name | Type | Length | Decimals |
|---|---|---|---|---|
| 1 | FIELD_NAME | Character | 10 | 0 |
| 2 | FIELD_TYPE | Character | 1 | 0 |
| 3 | FIELD_LEN | Numeric | 3 | 0 |
| 4 | FIELD_DEC | Numeric | 4 | 0 |
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.
| See also: | COPY STRUCTURE EXTENDED, CREATE FROM, DbCopyStruct(), DbCopyExtStruct(), DbCreate(), DbStruct() |
| Category: | Database commands |
| Source: | rtl\dbstrux.prg |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// 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
http://www.xHarbour.com