Ibad Baig
Ibad Baig

Reputation: 2294

Composite key in SQLite

How to put a composite key in SQLite? In SQL Server, we select multiple columns and then Set Primary Key. What is the method in SQLite?

I'm using SQLite Database Browser to manage my DB structure, I don't find the option for putting a composite key in a table or maybe I'm missing something. Will some one help me out with this?

Upvotes: 8

Views: 10245

Answers (1)

hobbs
hobbs

Reputation: 240473

Put a PRIMARY KEY (col1, col2, col3) constraint in the CREATE TABLE statement. SQLite doesn't support changing a table's primary key after it's created (which is a bit of a silly idea anyway).

Upvotes: 10

Related Questions