What is an ObjectID?
An ObjectID is a unique, not null integer field used to uniquely identify rows in tables in a geodatabase. ObjectIDs are limited to 32-bit values, which store a maximum value of 2,147,483,647.
Tables that are created through ArcGIS, or created outside ArcGIS then registered with the geodatabase, automatically have an ObjectID field added to them. The values in this field are maintained by ArcGIS. The ObjectID is used by ArcGIS to do such things as scroll, display selection sets, and perform identify operations on features.
Since most ArcGIS for Desktop functionality requires that the ObjectID be unique, you must be sure that ObjectID values are not duplicated when working directly with the database outside of ArcGIS. For example, when creating views with a one-to-many relationship, there is the possibility that ObjectIDs will be duplicated. This causes inconsistent behavior in ArcGIS for Desktop functionality.
When is an ObjectID added to a table?
There are several ways an ObjectID is added to a table:
- An ArcGIS-maintained ObjectID field is automatically added to any table created using ArcGIS.
- If you register a table with the geodatabase that does not have a qualifying field, the geodatabase adds another field to the table that meets the requirements of an ObjectID and names it OBJECTID. If your table already contains a column that is named OBJECTID, the geodatabase adds a column named OBJECTID_1.
- If you register a table with the geodatabase and the table does contain a qualifying field (integer, not null), the existing column can be used as the ObjectID. Note:
If the existing, qualifying field is maintained by the database—for example, if it has an Identity property in SQL Server or a Sequence property in PostgreSQL—the database maintenance property is dropped from the field when the table is registered with the geodatabase. Once registered with the geodatabase, ArcGIS maintains the values in the qualifying ObjectID field.
- If you registered your table with ArcSDE using the sdetable or sdelayer command, you specified a row ID column at that time. You also specified whether that column is to be maintained by ArcSDE or by you (user maintained).
When you subsequently register the table with the geodatabase, the table's row ID will be used for the ObjectID if you specified an ArcSDE-maintained row ID column when you registered with ArcSDE. If you instead specified a user-maintained row ID, the geodatabase adds a new ObjectID column when you subsequently register the table with the geodatabase. This new ObjectID column supersedes the column you specified when you registered the table with ArcSDE. It also changes the data type of your user-defined row ID to a long integer.
Therefore, if you are going to register the table with the geodatabase after registering it with ArcSDE, you should register the row ID as maintained by ArcSDE.