我有一个关于”Insert into”命令的问题。

huangapple go评论47阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年2月14日 19:55:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/75447480.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定