Menu

Warning: This table is missing a primary key

0 votes

When I open the table properties for a specific table I see the message:

This table is missing a primary key. dbFront will do it's best to
allow you to edit and view the data but the lack of a primary key can
cause serious performance and functionality issues.

in How To by (3.9k points)

1 Answer

0 votes
 
Best answer

If a table does not have a primary key then dbFront is forced to compare all fields on the record to ensure that it has the correct record when asked to perform UPDATE or DELETE operations.

This is both highly inefficient and problematic especially for more complex field types. One of the most common issues is handling multiple records that have identical field values.

The best solution is to add a primary key to the table. Since you are on SQL Server you can add a primary key using the following SQL. This column that will automatically self-populate with unique values as you add new records.

-- add new "RowId" column, make it IDENTITY (= auto-incrementing)
ALTER TABLE dbo.YourTable ADD RowId INT IDENTITY(1,1);
GO

-- add new primary key constraint on new column
ALTER TABLE dbo.YourTable ADD CONSTRAINT PK_YourTable PRIMARY KEY CLUSTERED (RowId);
GO
by (47.1k points)
selected by
Welcome to the dbFront Q&A site, where you can ask questions and receive answers from other members of the community.
 | Minimalist Answer Theme by Digitizor Media
 |
Powered by Question2Answer
...