Discussion Locked

identity

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
What is data type identity in SQL? In adding new records with PL/SQL, how do I write it?

7 replies

by roc180

The identity data type is a unique id that can be used to identify a row in a table. The primary use for the identity data type is for maintaining the primary key in a table. Unfortunatly I am not that familiar with PL/SQL, so I can't explain how to write it.

Good Luck

Neal Martinelli

by pvp

Identity is not a datatype, it's a property!

Which datatypes can be used with the identity property depends on which database server you're running. It's going to be a numeric type, but Sybase requires numeric(n,0); other products allow any number (int, float, etc.) or a subset of numeric types.

by glen_mcleod

In Oracle (I assume, because you mention PL/SQL), what you're describing is a Sequence, and yes, it is a property of the column. (Identity property is Sybase and MS SQL Server.) You'd have to check the Oracle documentation for the exact base type(s) allowed for the column, in SQL Server it's integer.

When you add a record to a table that has this type of column, you don't specify a value for the column because the DB engine takes care of it. If the increment is 1, then the value will be Max(column) + 1. If the increment is 10, then it'll be Max(column) + 10.

Glen

This discussion is closed to new replies.