How To: Select an existing field as the ObjectID field when adding a database table in ArcGIS Pro
All layers in ArcGIS require a unique identifier. Since the value in the unique identifier field identifies a row or feature object within ArcGIS, values in this field must always be unique and not null. ArcGIS does not enforce the uniqueness of values in the unique identifier field used in a query layer or database table. The user must ensure values in this field meet the requirements.
When adding a database table by dragging it from the Catalog pane to the map in ArcGIS Pro, ArcGIS uses the first not-null field as the unique identifier field or the ObjectID field by default. However, a not-null field with non-unique values may cause inconsistent results when performing queries on the database table.
Add the database table by creating a query layer in the map instead of dragging the database table from the Catalog pane to the map. Select the field(s) in the database table to be used as the ObjectID field. To add a query layer and select the field(s) as the ObjectID field, follow the steps below:
- With the project open, click Add Data and click Query Layer.
- In the New Query Layer dialog box, select the connected database where the table is stored from the Connection drop-down list.
Note: If the connection does not exist in the project, select the new database connection button and create a new connection to the database where the table is stored. For more information on database connections, refer to ArcGIS Pro: Database connections in ArcGIS Pro.
- Under List of Tables, select the database table.
- Click Validate. Once the database table is validated, click Next.
- Under Unique Identifier Field(s), check the field(s) to be the unique identifier fields(s).
- Click Finish. A query layer is created with the selected unique identifier field(s) as the ObjectID field.
- ArcGIS Pro: What is a query layer?
- ArcGIS Pro: View data from a database in ArcGIS
- ArcGIS Pro: Create a query layer
- ArcGIS Pro: Choose a unique identifier field for a query layer
- ArcGIS Pro: Database connections in ArcGIS Pro