Problem with Composite Primary Key ? #4112
Unanswered
RuudSchmeitz
asked this question in
Q&A
Replies: 1 comment 3 replies
-
This is behavior defined by SQLite, not SQLiteStudio and it is expected. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I created table
X
with a composite primary key :CREATE TABLE X (A TEXT, B TEXT, PRIMARY KEY (A, B) );
Then I tried to insert 4 rows into table
X
:INSERT INTO X (A, B) VALUES ('test1', 'test2');
INSERT INTO X (A, B) VALUES ('test1', 'test2');
INSERT INTO X (A, B) VALUES ('test1', NULL);
INSERT INTO X (A, B) VALUES ('test1', NULL);
As expected , the first INSERT statement executed OK , and the second does not :
"Error while executing SQL query on database 'MyPrivData': UNIQUE constraint failed: X.A, X.B"
Again as expected , no problems with the third statement .
But surprisingly , the fourth statement executed OK as well , resulting in :
Aren't the last 2 rows identical ?
Is that consistent with PRIMARY KEY (A, B) ?
Beta Was this translation helpful? Give feedback.
All reactions