Reputation: 2687
I use sqlite(3.7.4) in iphone. I create a table like:
create table A (UserName varchar (50) primary key, Num integer);
Then I insert the record below twice:
('abc',1);
Normally there should be only one record in DB. However I found in the DB
(abc,1);
( ,1);
I'm confused that as UserName is primary key
and why there are two records!
I don't know what's the problem.
Can anyone help me?
thank you.
Upvotes: 1
Views: 1262
Reputation: 5456
Why you want use username as primary key. Primary key should unique identify record. What is why when you inserted twice in second time you have primary key constraint violation
create table A (UserName varchar (50) primary key, Num integer, unique (UserName));
Upvotes: 1