Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 900
Ibad Baig Avatar asked Jun 22 '26 21:06

Ibad Baig


1 Answers

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).

like image 138
hobbs Avatar answered Jun 25 '26 01:06

hobbs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!