When deploying an application, you must assign a different identification number to each database. You can create and distribute the identification numbers by a variety of means. One method is to place the values in a table and download the correct row to each database based on some other unique property, such as remote ID.
In SQL Anywhere, you set the global ID of a database by setting the value of the public option global_database_id. The identification number must be a non-negative integer. See global_database_id option [database].
In UltraLite, you set the global ID of a database by setting the global_id option. See UltraLite global_database_id option.
The global database ID is set with the public option global_database_id in SQL Anywhere, and with the global_id option in UltraLite.
The global database id option in each database must be set to a unique, non-negative integer. The range of default values for a particular database is pn + 1 to p(n + 1), where p is the partition size and n is the value of the global database ID. For example, if the partition size is 1000 and global database ID is set to 3, then the range is from 3001 to 4000.
SQL Anywhere and UltraLite choose default values by applying the following rules:
If the column contains no values in the current partition, the first default value is pn + 1, where p is the partition size and n is the value of the global database ID.
If the column contains values in the current partition, but all are less than p(n + 1), the next default value is one greater than the previous maximum value in this range.
Default column values are not affected by values in the column outside the current partition; that is, by numbers less than pn + 1 or greater than p(n + 1). Such values may be present if they have been replicated from another database via MobiLink synchronization.
If the global database ID is set to the default value of 2147483647, a null value is inserted into the column. Should null values not be permitted, the attempt to insert the row causes an error. This situation arises, for example, if the column is contained in the table's primary key.
Because the global database ID cannot be set to negative values, the values chosen are always positive. The maximum identification number is restricted only by the column data type and the partition size.
Null default values are also generated when the supply of values within the partition has been exhausted. In this case, a new global database ID value should be assigned to the database to allow default values to be chosen from another partition. Attempting to insert the null value causes an error if the column does not permit nulls. To detect that the supply of unused values is low and handle this condition, you can create an event of type GlobalAutoincrement.
Should the values in a particular partition become exhausted, you can assign a new global database ID to that database. You can assign new database ID numbers in any convenient manner. However, one possible technique is to maintain a pool of unused database ID values. This pool is maintained in the same manner as a pool of primary keys.
You can set an event handler to automatically notify the database administrator (or perform some other action) when the partition is nearly exhausted. For SQL Anywhere databases, see Defining trigger conditions for events.
In a SQL Anywhere database, the following statement sets the database identification number to 20.
SET OPTION PUBLIC.global_database_id = 20 |
If the partition size for a particular column is 5000, default values for this database are selected from the range 100001-105000.
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |