Collection Contents Index Using additional dbspaces Using the utility database pdf/chap23.pdf

User's Guide
   PART 4. Database Administration and Advanced Use
     CHAPTER 23. Working with Database Files       

Working with write files


If you have a database file that is read-only (for example, if you distribute a database on a CD-ROM), you can use a write file to enable changes to be made to the database.

You create a write file using the Write File utility or using the CREATE WRITEFILE statement. In this section, the examples use the command-line utilities.

For Info     For a description of the CREATE WRITEFILE statement, see CREATE WRITEFILE statement.

  To use a write file:
  1. Create the write file for your database.

    For example, to create a write file for the sample database, you can enter the following command in the Adaptive Server Anywhere installation directory:

    dbwrite -c asademo.db

    This command creates a write file named asademo.wrt, with a transaction log named asademo.wlg.

  2. Start a database server, loading the write file. By default, the server locates files with the extension .wrt first, so the following command in the installation directory starts the personal server running the sample database write file:

    dbeng6 asademo

    The messages on the server window indicate which file is started.

  3. Connect to the database using Interactive SQL. You can use the user ID DBA and the password SQL, as the sample database is the default.

  4. You can execute queries just as usual. The following query lists the contents of the department table.

    SELECT *
    FROM department
  5. Try inserting a row. The following statement inserts a row into the department table:

    INSERT
    INTO department (dept_id, dept_name)
    VALUES (202, 'Eastern Sales')

    If you committed this change, it would be written to the asademo.wlg transaction log, and when the database checkpoints, it is written to the asademo.wrt write file.

    If you now query this table, the results are taken from the write file and the database file.

  6. Try deleting a row. Set the WAIT_FOR_COMMIT option to avoid referential integrity complaints here:

    SET TEMPORARY OPTION wait_for_commit = 'on' ;
    DELETE
    FROM department 
    WHERE dept_id = 100

    If you committed this change, the deletion would be marked in the write file. No change is made to the database file.

For some purposes, it is useful to use a write file with a shared database. If you have a read-only database on a network server, you could let each user have their own write file. In this way, they could add their own information, which would be stored on their own machine, without affecting the database. This can be useful for application development also.

Deleting a write file 

You can use the dberase utility to delete a write file and its associated transaction log.


Collection Contents Index Using additional dbspaces Using the utility database pdf/chap23.pdf