Youassign each copy of the database a unique global database identification
number. AdaptiveServer Anywhere supplies default values in a database
onlyfrom the partition uniquely identified by that database’s number.
Forexample, if you assigned the database in the above example the identity
number10, the default values in that database would be chosen in the range
10001–11000. Another copy of the database, assigned the identification
number11, would supply default value for the same column in the range
11001–12000.
Declaring default global autoincrement
Youcan set default values in your database by selecting the column
propertiesin Sybase Central, or by including the DEFAULT GLOBAL
AUTOINCREMENTphrase in a TABLE or ALTERTABLE statement.
Optionally,the partition size can be specified in parentheses immediately
followingthe AUTOINCREMENT keyword. The partition size may be any
positiveinteger, although the partition size is generally chosen so that the
supplyof numbers within any one partition will rarely, if ever, be exhausted.
Forcolumns 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 our
columnis not of type INT or BIGINT, it is best to specify the partition size
explicitly.
Forexample, the following statement creates a simple table with two
columns: an integer that holds a customer identification number and a
characterstring that holds the customer’s name.
CREATE TABLE customer (
id INT DEFAULT GLOBAL AUTOINCREMENT (5000),
name VARCHAR(128) NOT NULL,
PRIMARY KEY (id)
)
Inthe above example, the chosen partition size is 5000.
Formore information on GLOBAL AUTOINCREMENT, see
“CREATETABLE statement” [ASA SQL Reference,page 407].
Setting the Global_database_id value
Whendeploying an application, you must assign a different identification
numberto each database. Youcan accomplish the task of creating and
distributingthe identification numbers by a variety of means. Onemethod is
toplace the values in a table and download the correct row to each database
basedon some other unique property, such as user name.
130