Skip to content

Editing primary keys

A primary key uniquely identifies each row in a table. To define or change it, open the table in the designer and go to the Primary Key sub-tab.

The Primary Key sub-tab The Primary Key sub-tab

You can set the following properties for the primary key:

  • Constraint name โ€” an optional name for the primary-key constraint.
  • Conflict clause โ€” what SQLite does if an insert or update would violate the key (ROLLBACK, ABORT, FAIL, IGNORE, or REPLACE).
  • Columns โ€” the column or columns that make up the key.

Note

A table can have only one primary key. If it consists of a single column, SQLite Expert writes it as a column constraint; if it spans several columns, it becomes a table constraint.

Autoincrement columns

SQLite can automatically assign an ever-increasing value to a key column, but only when the primary key is a single INTEGER column. To set one up, define a single-column INTEGER primary key on the Primary Key tab, then tick the Autoincrement option.

The primary key column dialog The primary key column dialog

See also: Editing columns ยท Editing constraints