Is it OK to use a NOT NULL on a primary key in SQLite?

1

My question is, is it correct to define as NOT NULL in a primary call in a database SQLite for Android ?, example:

ID INTEGER NOT NULL PRIMARY KEY 
    
asked by Jorge Luis Pilo Torres 30.08.2016 в 18:09
source

1 answer

6

In SQLite (and other databases), if you declare a field as Primary Key it is necessary that it is set as NOT NULL , since you never must have null values

Although in SQLite if you declare your field as Primary Key , they are automatically set to NOT NULL .

create table Personas (
  P_Id number primary key,
  LastName varchar(255),
  FirstName varchar(255) not null
);
    
answered by 30.08.2016 / 18:25
source