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

SQL Anywhere 11.0.1 (Français) » SQL Remote » SQL Remote Replication Design » SQL Remote replication design and set up » Duplicate primary key errors » Global autoincrement columns

 

Declaring DEFAULT GLOBAL AUTOINCREMENT

You can set default values in your database by selecting the column properties in Sybase Central, or by including the DEFAULT GLOBAL AUTOINCREMENT clause in a CREATE TABLE or ALTER TABLE statement.

Partition size

Optionally, the partition size can be specified in parentheses immediately following the AUTOINCREMENT keyword. The partition size may be any non-negative integer, although the partition size is generally chosen so that the supply of numbers within any one partition is rarely 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, especially if your column is not of type INT or BIGINT, it is recommended that you specify the partition size explicitly.

Example

The following statement creates a table with two columns: an integer that holds a customer identification number and a character string that holds the customer's name. The identification number column, ID, uses the GLOBAL AUTOINCREMENT default and has a partition size of 5000.

CREATE TABLE Customers (
   ID   INT  DEFAULT GLOBAL AUTOINCREMENT (5000),
   name VARCHAR(128) NOT NULL,
   PRIMARY KEY (ID)
);
See also