# Primary Key

> Part of the NocoDB documentation (Product docs > Tables > Fields). Index of all pages: https://nocodb.com/llms.txt. Any docs page is available as Markdown by adding `.md` to its URL.

URL: https://nocodb.com/docs/product/tables/fields/primary-key
Last updated: 2026-10-03

Learn what a primary key is and how NocoDB sets and uses the primary key of a table.

A primary key is a special field in a database table. It identifies each record in the table uniquely. NocoDB uses the primary key internally for all operations on a record.

## Primary Key in NocoDB

The primary key that NocoDB uses depends on how the table was created:

1. From the UI: Create new table, Import from Excel, or Import from CSV
   1. NocoDB creates an `ID` \[datatype: Integer] system field by default when it creates the table. This field is the primary key.
   2. NocoDB also adds the system fields `created-at` and `updated-at` by default.

2. Connect to an existing external database
   1. NocoDB keeps the existing `primary key` field of the table. NocoDB does not add a new ID field.
   2. NocoDB does not add the system fields `created-at` and `updated-at` by default.

3. Import from Airtable
   1. The Airtable record ID is the primary key for imported records. It maps to the field `ncRecordId` \[datatype: varchar].
   2. If you add a new record after migration without a value for `ncRecordId`, NocoDB inserts an automatically generated string.
   3. NocoDB stores a hash value of the full record in the system field `ncRecordHash`.
   4. NocoDB does not add the system fields `created-at` and `updated-at` by default.

4. Create a new table with the SDK or API
   1. NocoDB does not add a default primary key field. You must set it when you create the table, with the attribute `pk: true`.

### FAQ

**What if Primary Key was missing?**

In NocoDB, a table can have no primary key. This happens when the table is created externally, or through the SDK or API without a primary key. You can add new records to this table. You cannot update or delete records, because no unique identifier points to each record.

**Can I change the Primary Key to another field within tables?**

You cannot change the Primary Key from the NocoDB UI. Change it directly in the database, and then run `meta sync` manually.

---

## Related pages

- [Display Value](https://nocodb.com/docs/product/tables/fields/display-value.md): The display value is the field that identifies each record in a NocoDB table; learn what it does and how to set it.
- [Multi-Field Editor](https://nocodb.com/docs/product/tables/fields/multi-fields-editor.md): Use the multi-field editor in NocoDB to add, edit, delete, reorder, and hide many fields of a table at one time.
- [Field Summary](https://nocodb.com/docs/product/tables/fields/field-summary-footer.md): The NocoDB field summary shows calculations such as sum, average, minimum and maximum for a field in the footer of a grid view.
- [Actions on Field](https://nocodb.com/docs/product/tables/fields/actions-on-field.md): Actions on a NocoDB field: rename it, change its type, default value and width, hide it, sort by it, duplicate, insert, delete and describe it.
