+ 1

In SQL, is it a must I indicate a primary key? Can't my first column which has int as datatype be the primary key by default?

Database

27th Mar 2019, 5:20 PM
Babatunde Akinola
Babatunde Akinola - avatar
3 ответов
+ 5
Yes, pk is required. But pk is a combination of NOT NULL and UNIQUE. So a email address can be a pk, too. Check the sl course for the full sytax of relation declaration.
27th Mar 2019, 6:09 PM
SouthPoleHillbilly
SouthPoleHillbilly - avatar
+ 3
You're welcome CREATE TABLE Users ( UserID int, FirstName varchar(100), LastName varchar(100), City varchar(100), PRIMARY KEY(UserID) );
27th Mar 2019, 6:30 PM
SouthPoleHillbilly
SouthPoleHillbilly - avatar
+ 1
Thanks
27th Mar 2019, 6:15 PM
Babatunde Akinola
Babatunde Akinola - avatar