sql - 插入语句试图包含重复键

标签 sql database oracle syntax syntax-error

努力奔跑

INSERT INTO BOOKING_EXTRAS (BOOKING_ID, EXTRAS_, EXTRAS_PRICE) VALUES ('1','Phone call: 1.80','1.8');

在 Oracle SQL Developer 中。我让它运行但是当我关闭它然后重新打开它时我得到这个错误:

Error starting at line 1 in command:
INSERT INTO BOOKING_EXTRAS (BOOKING_ID, EXTRAS_, EXTRAS_PRICE) VALUES ('1','Phone call: 1.80','1.8')
Error report:
SQL Error: ORA-00001: unique constraint (COURSEWORK_XE.BOOKING_EXTRAS_PK) violated
00001. 00000 -  "unique constraint (%s.%s) violated"
*Cause:    An UPDATE or INSERT statement attempted to insert a duplicate key.
       For Trusted Oracle configured in DBMS MAC mode, you may see
       this message if a duplicate entry exists at a different level.
*Action:   Either remove the unique restriction or do not insert the key.

我该如何解决这个问题?它发生在我经营的每张 table 上!

最佳答案

您需要清除表或插入新信息,数据库不想要重复的行,因为这使得以后无法找到正确的行。

关于sql - 插入语句试图包含重复键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19817731/

相关文章:

database - 在数据库列中存储分隔列表真的那么糟糕吗?

sql - Postgres : Find position of a specific row within a resultset?

php - Mysql 查询连接表列

mysql - 处理整个数据库以获取数据

mysql - 对结果集执行 Post SQL 查询?

sql - PostgreSQL - 错误 : relation "table_name" does not exist. 如何在没有架构名称的情况下进行查询?

sql - CREATE TABLE 语句中缺少右括号

linux - ORA-00119 : invalid specification for system parameter LOCAL_LISTENER

sql - 在ESQL中验证结果

mysql - 事件记录 : LEFT OUTER self-JOIN with conditions on joined table