Contents Index Global autoincrement default column values Setting the global database identifier pdf/preface.pdf

UltraLite User's Guide
  Designing UltraLite Applications
    Global autoincrement default column values

Declaring default global autoincrement columns


You declare default column values in the Adaptive Server Anywhere reference database. When you build your UltraLite application, your UltraLite database inherits the default column value. You can set default values in your reference database by selecting the column properties in Sybase Central, or by including the DEFAULT GLOBAL AUTOINCREMENT phrase in a TABLE or ALTER TABLE statement.

Optionally, the partition size can be specified in parentheses immediately following the AUTOINCREMENT keyword. The partition size may be any positive integer, although the partition size is generally chosen so that the supply of numbers within any one partition will rarely, if ever, be exhausted.

For columns of type INT or UNSIGNED INT, the default partition size is 216  = 65536; for columns of other types the default partition size is 232 = 4294967296. Since these defaults may be inappropriate it is best to specify the partition size explicitly.

For example, the following statement creates a simple reference table with two columns: an integer that holds a customer identification number and a character string that holds the customer's name.

CREATE TABLE customer (
   id   INT          DEFAULT GLOBAL AUTOINCREMENT (5000)
   name VARCHAR(128) NOT NULL
   PRIMARY KEY (id)
)

In the above example, the chosen partition size is 5000.

Default partition sizes for some data types are different in UltraLite applications than in Adaptive Server Anywhere databases. Declare the partition size explicitly if you wish the reference database to behave in the same manner as your UltraLite application.

For more information on GLOBAL AUTOINCREMENT, see CREATE TABLE statement.


Contents Index Global autoincrement default column values Setting the global database identifier pdf/preface.pdf