The IDENTITY column stores sequential numbers, such as invoice numbers or employee numbers, which are automatically generated. The value of the IDENTITY column uniquely identifies each row in a table.
In Adaptive Server Enterprise, each table in a database can have one IDENTITY column. The data type must be numeric with scale zero, and the IDENTITY column should not allow nulls.
In SQL Anywhere, the IDENTITY column is a column default setting. You can explicitly insert values that are not part of the sequence into the column with an INSERT statement. Adaptive Server Enterprise does not allow INSERTs into identity columns unless the identity_insert option is on. In SQL Anywhere, you need to set the NOT NULL property and ensure that only one column is an IDENTITY column. SQL Anywhere allows any numeric data type to be an IDENTITY column. The use of integer data types is recommended for better performance.
In SQL Anywhere, the IDENTITY column and the AUTOINCREMENT default setting for a column are identical.
To create an IDENTITY column, use the following CREATE TABLE syntax, where n is large enough to hold the value of the maximum number of rows that may be inserted into the table:
CREATE TABLE table-name ( ... column-name numeric(n,0) IDENTITY NOT NULL, ... )
Discuter à propos de cette page dans DocCommentXchange.
|Copyright © 2013, SAP AG ou société affiliée SAP - SAP Sybase SQL Anywhere 16.0|