Locking shared data
By definition, all database files can be used by many users at the same time. However, some operations can lock files, members, or records to prevent them from being shared across jobs.
When files, members, or records are locked, no other jobs can read the same data for update operations, which keeps another job from unintentionally deleting the first job's update.
You can lock a row in iSeriesā¢ Navigator by opening a table and editing the row you want to lock, or use the SQL LOCK TABLE statement. You can also use the following operations to lock files, members, or data records, and display locked records using the Display Record Locks (DSPRCDLCK) command or iSeries Navigator.
- Locking records
DB2 Universal Databaseā¢ for iSeries has built-in integrity for records.
- Locking files
When a database file is allocated exclusively, any program trying to open the file has to wait until it is released. However, you can set a wait time for the file to become available using the WAITFILE parameter.
- Locking members
Member operations (such as add and remove) automatically allocate the file exclusively to prevent other file operations from occurring at the same time.
- Locking record format data
Sometimes you might want to lock the entire set of records associated with a record format (for example, all the records in a physical file). In this case, you can use the RCDFMTLCK parameter on the Override Database File (OVRDBF) command.
- Database lock considerations
These tables show the types of locks that some of the database functions place on database files, the valid lock combinations, and the types of locks for constraints.
- Displaying locked rows using iSeries Navigator
You can use iSeries Navigator to display locked rows in a table.
- Displaying locked records using the Display Record Locks (DSPRCDLCK) command
You can use the Display Record Locks (DSPRCDLCK) command to display the current lock status (wait or held) of records in a physical file member.
Parent topic:
Database file processing: Runtime considerations
Related reference
LOCK TABLE