为什么我会收到此错误 ORA-00001:违反唯一约束 (HR.DEPT_ID_PK)?
Why I'm getting this error ORA-00001: unique constraint (HR.DEPT_ID_PK) violated?
我在这里向 oracle 11g 中的内置部门 table 插入行,但是当我执行查询时出现此错误
ORA-00001: unique constraint (HR.DEPT_ID_PK) violated.
帮助是一种进步。
enter code here
{
INSERT INTO HR.departments(department_id,
department_name, manager_id, location_id)
VALUES (70, 'Public Relations', 100, 1700);
}
表示table中已有70个可用departmetn_id。请检查。然后更改您要插入的 department_id。
也许您的意图是更新现有行而不是插入新行:
UPDATE HR.departments
SET (department_name, manager_id, location_id) = ('Public Relations', 100, 1700)
WHERE department_id = 70;
我在这里向 oracle 11g 中的内置部门 table 插入行,但是当我执行查询时出现此错误
ORA-00001: unique constraint (HR.DEPT_ID_PK) violated.
帮助是一种进步。
enter code here
{
INSERT INTO HR.departments(department_id,
department_name, manager_id, location_id)
VALUES (70, 'Public Relations', 100, 1700);
}
表示table中已有70个可用departmetn_id。请检查。然后更改您要插入的 department_id。
也许您的意图是更新现有行而不是插入新行:
UPDATE HR.departments
SET (department_name, manager_id, location_id) = ('Public Relations', 100, 1700)
WHERE department_id = 70;