How to specify primary key on multiple columns in SQLite?

In SQLite, you can specify the primary key of a table on multiple table columns. Here is the generic syntax:

CREATE TABLE table_name (
  column1,
  column2,
  column3,
  PRIMARY KEY (column1, column2)
);

Example:

CREATE TABLE order (
    id INTEGER NOT NULL,
    payment_id INTEGER NOT NULL
    full_name TEXT NOT NULL,
    PRIMARY KEY (id, payment_id)
);

Need a good GUI tool for SQLite? Check out TablePlus. It’s native, beautiful, and available for free.

Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

On Linux? Download TablePlus for Linux

Need a quick edit on the go? Download TablePlus for iOS

TablePlus GUI Tool SQLite