Contents Index Particular concurrency issues Data definition statements and concurrency

ASA SQL User's Guide
  Using Transactions and Isolation Levels
    Particular concurrency issues

Primary key generation


You will encounter situations where the database should automatically generate a unique number. For example, if you are building a table to store sales invoices you might prefer that the database assign unique invoice numbers automatically, rather than require sales staff to pick them.

There are many methods for generating such numbers.

Example 

For example, invoice numbers could be obtained by adding 1 to the previous invoice number. This method will not work when there is more than one person adding invoices to the database. Two people may decide to use the same invoice number.

There is more than one solution to the problem:

Unique values in replicated databases 
Different techniques are required if you replicate your database and more than one person can add entries which must later be merged. For more information, see Replication and concurrency.

Contents Index Particular concurrency issues Data definition statements and concurrency