Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.1 » MobiLink - Server Administration » MobiLink server technology » Synchronization techniques » Unique primary keys

 

Using GLOBAL AUTOINCREMENT

In SQL Anywhere and UltraLite databases, you can set the default column value to be GLOBAL AUTOINCREMENT. You can use this default for any column in which you want to maintain unique values, but it is particularly useful for primary keys.

GLOBAL AUTOINCREMENT values are partitioned among remote databases in contiguous ranges of values. The set of possible values is finite, so the larger the size of the each range, the fewer ranges are available. Care must be taken to set the correct size of the range for your needs. Exhausting a range is possible, but you can detect this and assign a new range. See How default values are chosen.

 Use GLOBAL AUTOINCREMENT columns
  1. Declare the column as a GLOBAL AUTOINCREMENT column.

    When you specify DEFAULT GLOBAL AUTOINCREMENT, the domain of values for that column is partitioned. Each partition contains the same number of values. For example, if you set the partition size for an integer column in a database to 1000, one partition extends from 1001 to 2000, the next from 2001 to 3000, and so on.

    See Declaring DEFAULT GLOBAL AUTOINCREMENT.

  2. Set the global_database_id value.

    SQL Anywhere and UltraLite databases supply default values in a database only from the partition uniquely identified by that database's number. For example, if you assign a database the identity number 10 and the partition size is 1000, the default values in that database would be chosen in the range 10001-11000. Another copy of the database, assigned the identification number 11, would supply default value for the same column in the range 11001-12000.

    See Setting the global database ID.


Declaring DEFAULT GLOBAL AUTOINCREMENT
Setting the global database ID