Why there is no primary key for tables

3449
7
01-21-2018 09:46 PM
ModyBuchbinder
Esri Regular Contributor

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

0 Kudos
7 Replies
shan_sarkar
Frequent Contributor

Mody,

Is BBB table is a non-spatial table?

~Shan


~Shan
0 Kudos
ModyBuchbinder
Esri Regular Contributor

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

0 Kudos
Asrujit_SenGupta
MVP Regular Contributor

There is a Unique Key created in case of Tables:

 

0 Kudos
ModyBuchbinder
Esri Regular Contributor

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

0 Kudos
Asrujit_SenGupta
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?"

Asrujit_SenGupta
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. 

0 Kudos
FredSpataro
Frequent Contributor

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.  

0 Kudos