Postgres No Primary Key Drawback

Postgresql

Postgresql Problem Overview


Is there any drawback to not having a primary key for a table in Postgres? Since all data is stored unordered in the heap anyway, is the primary key just a way to enforce a unique key and an index at the same time? Or is there a fundamental feature that a primary key provides in a table as opposed to a table that does not have a primary key?

Postgresql Solutions


Solution 1 - Postgresql

Per the Postgres documentation (http://www.postgresql.org/docs/9.2/static/sql-createtable.html):

> Technically, PRIMARY KEY is merely a combination of UNIQUE and NOT > NULL, but identifying a set of columns as primary key also provides > metadata about the design of the schema, as a primary key implies that > other tables can rely on this set of columns as a unique identifier > for rows.

From my experience, I have created plenty of tables without them. But some replication solutions require there be a primary key, or at the single column identifier per row.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlexGadView Question on Stackoverflow
Solution 1 - PostgresqljcernView Answer on Stackoverflow