Exclusive Lock : Prevents any other type of concurrent access
   Write Lock :       Prevents other read,write,exclusive locks
   Read Lock :        Prevents  read,write,exclusive locks
   Access Lock :     Prevents exclusive locks only

Locks may be applied at  the following levels:

      Database : Applied to all tables/views in the table
 Table/view : Applies to all rows in the table/views
 Row hash : Applies to all rows with same row hash

Locks at row level:

  Syntax:- Locking row for <lock type><sql query>
       Ex:-  Locking row for access   select*from party;
                Locking row for     write insert into party values ();

Locks at table level:

   Syntax:-locking table <table name>for <lock type>;
          Ex:-locking table party for access;

Releasing lock:

   Syntax: release lock database name ‘table name’;

Advantages:


  •  Permit quicker access to table in multi-user environment
  •  Have ‘minimal’effect on other queries
  •  Very useful for aggregating large number of rows

Dis advantages:

  • May produce erroneous results if during table maintenance.