sqliteprimary-keyddlcomposite-primary-key

SQLite primary key on multiple columns


What is the syntax for specifying a primary key on more than 1 column in SQLite ?


Solution

  • According to the documentation on CREATE TABLE, specifically table-constraint, it's:

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