db_create
| Definition: | integer i = db_create(string st, integer locktype) |
| Description: | Create a new database. A new database will be created in the file with path given by st. locktype indicates the type of lock that will be applied to the file as it is created. i is an error code that indicates success or failure. The values for locktype can be either DB_LOCK_NO (no lock) or DB_LOCK_EXCLUSIVE (exclusive lock). i is DB_OK if the new database is successfully created. This database becomes the current database to which all other database operations will apply. |
| pwa/p2js: | Not supported |
| Comments: | If the path does not end in .edb, it will be added automatically.
A version number is stored in the database file so future versions of the database software can recognize the format, and possibly read it and deal with it in some way. The return codes are: DB_OK(0) - success (also returned by several other routines), DB_OPEN_FAIL(-1) - could not open the file (also returned by db_open and db_select_table), DB_EXISTS_ALREADY(-2) -- file already exists (also returned by db_insert), and theoretically DB_LOCK_FAIL(-3). |
| Example: |
if db_create("mydata", DB_LOCK_NO)!=DB_OK then
puts(2, "Couldn't create the database!\n")
abort(1)
end if
|
| See Also: | db_open, db_close |