Why there is no primary key for tables

904
7
01-21-2018 09:46 PM
Highlighted
Regular Contributor II

In Sql Server when I create a layer the OBJECTID is defined as primary key.

When I create a table (using ArcMap) the OBJECTID is not define as primary key.

See the screen shot, AAA is a layer (have a shape filed), BBB is a table.

Any reason for this?

Thanks

Mody

Reply
0 Kudos
7 Replies
Highlighted
Regular Contributor

Mody,

Is BBB table is a non-spatial table?

~Shan

Reply
0 Kudos
Highlighted
Regular Contributor II

Yes I just did right click on the database connection and select  New->Table

Reply
0 Kudos
Highlighted
MVP Regular Contributor

There is a Unique Key created in case of Tables:

 

Reply
0 Kudos
Highlighted
Regular Contributor II

Index is not the same as primary key

See the key icon next to the OBJECTID field that exists in TESTFC and does not exists in TESTTABLE

Reply
0 Kudos
Highlighted
MVP Regular Contributor

What is an ObjectID?—Help | ArcGIS Desktop 

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.

So this satisfies the requirement for an ObjectID atleast.

Yes, they may not be the same and hence the question could be "Why does ArcGIS create a Primary Key in case of Feature Classes, but a Unique Index in case of Geodatabase Tables?"

Highlighted
MVP Regular Contributor

From a quick test, it seems the behaviour is not same in an Oracle Enterprise gdb.

A Feature Class created in an Oracle sde gdb, does not have the ObjectID as a Primary Key. 

Reply
0 Kudos
Highlighted
Occasional Contributor III

I just ran into this issue... oddly it appears to be different if the database is 'geodatabase enabled' or not ... at least on SQL Server.  I just created a table via ArcCatalog on a plain/non-geodatabase database connection and the OBJECTID column is set as the primary key by default.  

Reply
0 Kudos