英文:
I have a problem with the Insert into command
问题
抱歉,我在尝试为我的属性赋值时遇到了错误。我不太清楚问题出在哪里。有关信息:我先前成功创建了8个表,并且我正在使用SQLite Online。这里是图片
希望有人能解决我的问题。
英文:
Unfortunately I get an error when I wanted to put the values for my attributes. I don't know exactly what the problem is. For Info : I have previously created 8 tables successfully and i use SQLite Online.Here is the picture
I hope that someone can solve my problem.
答案1
得分: 1
如果表格具有唯一约束,这意味着某一列(或一组列)的值必须是唯一的,即不能在表中的不同行中重复出现。
您正试图插入一个破坏该约束的新记录,也就是说新行包含在表中已经存在的具有相同值组合的约束列中的值。
例如:
CREATE TABLE t1 (id INT, firstname, surname TEXT, UNIQUE (id, surname));
INSERT INTO t1 VALUES (1, 'John', 'Doe');
INSERT INTO t1 VALUES (1, 'Bob', 'Doe'); -- 唯一约束失败:t1.id, t1.surname
英文:
If a table has a UNIQUE constraint, it means the value of a column (or set of columns) must be unique, i.e. cannot be repeated for different rows in the table.
You're trying to insert a new record that breaks that constraint, i.e. the new row contains values in the constraint columns that already exist in the table with the same combination of values.
For example:
CREATE TABLE t1 (id INT, firstname, surname TEXT, UNIQUE (id, surname));
INSERT INTO t1 VALUES (1, 'John', 'Doe');
INSERT INTO t1 VALUES (1, 'Bob', 'Doe'); -- UNIQUE constraint failed: t1.id, t1.surname
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论