This article shows you how to add, create or modify a SQL primary key constraint
The following schemas are logically equivalent because the primary keys are implemented by creating a unique index in the database.
CREATE TABLE t1(a, b PRIMARY KEY); -- no name)
CREATE TABLE t1 ( a, b CONSTRAINT t1b PRIMARY KEY) ;
CREATE TABLE t1(a, b UNIQUE);
CREATE TABLE t1(a, b);
CREATE UNIQUE INDEX t1b ON t1(b);
Multiple columns are also known as composite
CREATE TABLE EVENTS_QUEUE
(
NAME TEXT, -- Name
DATA_HASH TEXT, -- Data Hash
DATA TEXT, -- DataS
constraint pk_events_queue primary key (NAME, DATA_HASH)
);
The alter statement is limited within SQLite, you need to create a new table and move the data.
See How to alter an SQLite table?
PRIMARY KEY constraints are implemented by creating a unique index in the database.
The exceptions in Sqlite are: