Contents Index Maintaining unique primary keys Maintaining unique primary keys using global autoincrement

MobiLink Synchronization User's Guide
  Synchronization Techniques
    Maintaining unique primary keys

Maintaining unique primary keys using UUIDs


You can ensure that primary keys in Adaptive Server Anywhere databases are unique by using the newid( ) function to create universally unique values for your primary key. The resulting UUIDs can be converted to a string using the uuidtostr( ) function, and converted back to binary using the strtouuid( ) function.

UUIDs are unique across all computers. However, the values are completely random and so cannot be used to determine when a value was added, or the order of values. UUID values are also considerably larger than the values required by other methods (including global autoincrement), and require more table space in both the primary and foreign key tables. Indexes on tables using UUIDs are also less efficient.

For more information, see

Example 

The following CREATE TABLE statement creates a primary key that is universally unique:

CREATE TABLE customer (
   cust_key BINARY(16) NOT NULL
            DEFAULT newid( )
   rep_key VARCHAR(5)
   PRIMARY KEY(cust_key)

Contents Index Maintaining unique primary keys Maintaining unique primary keys using global autoincrement