0

Can a Primary key column accept the Null value? I'm using SQLiteStudio for learning and it accepts.

It is accepting multiple null values in the table of 5 columns, where the following query is executed:

Insert into EmployeeDB (Name, Age)
Values ('Raja3', '85');

Here 2 columns are given a value, so all other columns are updated as Null in which one column is defined as PRIMARY Key and one as UNIQUE.

3 Answers3

1

Primary key can't accept NULL values. Unique key can accept only ONE NULL values.

Can i know which column is defined as primary key and which one is defined as Unique key. If possible show me the Structure of the table

Kannan
  • 11
  • 2
1

Well, Unless the Column is an Integer Primary Key, SQLite (Only SQLite) allows Primary Key to Possess a Null Value. NULL values are considered distinct from all other values, including other NULLs. This can be resolved by adding NOT NULL constraint to the Column Field.

Vatsal Prakash
  • 558
  • 6
  • 17
  • This is working when I configure the column to 'Not null', but what is the purpose of Primary key? why the key feature of PK is not working? Pls help. – Sundarrajapandian Jun 02 '16 at 06:52
  • There are some inconsistencies with SQLite. By the times this issue was discovered, SQLite was in a wide use and fixing the problem could have created havoc in the existing systems. It might get fixed in the Future.. :) – Vatsal Prakash Jun 02 '16 at 06:56
-2

Primary key column does not accept null values. It is not possible. Can you show properties of all columns in this table please?

PriVictor
  • 49
  • 5