1.0

Table Of Contents
GENERATED BY DEFAULT identity columns. Creating an identity column does not create an index on the
column.
For a GENERATED ALWAYS identity column, SQLFire increments the default value on every insertion, and
stores the incremented value in the column. You cannot insert a value directly into a GENERATED ALWAYS
identity column, and you cannot update a value in a GENERATED ALWAYS identity column. Instead, you
must either specify the DEFAULT keyword when inserting data into the table or you must leave the identity
column out of the insertion column list. For example, consider a table with the following column denition:
create table greetings (i int generated always as identity, ch char(50));
You can insert rows into the table using either the DEFAULT keyword, or by omitting the identity column from
the INSERT statement:
insert into greetings values (DEFAULT, 'hello');
insert into greetings(ch) values ('hi');
The values that SQLFire automatically generates for a GENERATED ALWAYS identity column are unique.
For a GENERATED BY DEFAULT identity column, SQLFire increments and uses a default value for an
INSERT only when no explicit value is given. To use the generated default value, either specify the DEFAULT
keyword when inserting into the identity column, or leave the identity column out of the INSERT column list.
In contrast to GENERATED ALWAYS identity columns, with a GENERATED BY DEFAULT column you
can specify an identity value to use instead of the generated default value. To specify a value, include it in the
INSERT statement.
For example, consider a table created using the statement:
create table greetings (i int generated by default as identity, ch char(50));
The following statement species the value "1" for the identity column:
insert into greetings values (1, 'hi');
These statements both use generated default values:
insert into greetings values (DEFAULT, 'hello');
insert into greetings(ch) values ('bye');
Although the automatically-generated values in a GENERATED BY DEFAULT identity column are unique, a
GENERATED BY DEFAULT column does not guarantee unique identity values for all rows in the table. For
example, in the above statements the rows containing "hi" and "hello" both have an identity value of "1." This
occurs because the generated column starts at "1" and the user-specied value was also "1."
To avoid duplicating identity values (for example, during an import operation), you can use the START WITH
clause to specify the rst identity value that SQLFire should assign and increment. Or, you can use a primary
key or a unique constraint on the GENERATED BY DEFAULT identity column to check for and disallow
duplicates.
By default, the initial value of a GENERATED BY DEFAULT identity column is 1, and the value is incremented
by 1 for each INSERT. Use the optional START WITH clause to specify a new initial value. Use the optional
INCREMENT BY clause to change the increment value used during each INSERT.
See also Auto-Generated Columns on page 653 for information about limitations with identity columns.
vFabric SQLFire User's Guide452
vFabric SQLFire Reference