简体   繁体   English

为什么有些用户而不是其他用户得到 ORA-01400: cannot insert NULL into primary key

[英]Why do some users and not others get ORA-01400: cannot insert NULL into primary key

I know how to fix it.我知道如何解决它。 I am just wondering why it worked on some developer machines and not others.我只是想知道为什么它适用于某些开发人员机器而不是其他机器。 I have replaced actual names and values for clarity.为了清楚起见,我已经替换了实际名称和值。

INSERT INTO MYTABLE (COL2, COL3, COL4, COL5, COL6) 
SELECT 0, 1, 2, 3, 4

My fix is我的解决方法是

INSERT INTO MYTABLE (COL1, COL2, COL3, COL4, COL5, COL6) 
SELECT MYTABLE_SEQ.NEXTVAL, 0, 1, 2, 3, 4

But why wasn't it necessary on all developer machines?但是为什么在所有开发人员机器上都没有必要呢?

The same table behaves the same way, so - if all of them (developers) used the same INSERT statement, connected to the same database (user), they'd get the same result - either success or a failure.同一个表的行为方式相同,所以 - 如果他们(开发人员)都使用相同的INSERT语句,连接到同一个数据库(用户),他们会得到相同的结果 - 成功或失败。


However, if they have their own schemas, then it depends on the way they created target tables.但是,如果他们有自己的模式,那么这取决于他们创建目标表的方式。

Behaviour you described could be result of您描述的行为可能是由于

  • identity column (12c onwards)身份列(从 12c 开始)
  • database trigger数据库触发器

which then "automatically", in the background , populate that NOT NULL column.然后在后台“自动”填充NOT NULL列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Hibernate和ORA-01400:无法插入NULL - Hibernate and ORA-01400: cannot insert NULL IntegrityError:ORA-01400:无法将NULL插入 - IntegrityError: ORA-01400: cannot insert NULL into INSERT失败,出现ORA-01400:无法插入NULL - INSERT fails with ORA-01400: cannot insert NULL Spring 启动错误 ORA-01400:无法将 NULL 插入(“AAKASH”.“USERS”.“EMAILVERIFICATIONSTATUS”) - Spring boot error ORA-01400: cannot insert NULL into (“AAKASH”.“USERS”.“EMAILVERIFICATIONSTATUS”) oci_execute():ORA-01400:无法插入NULL - oci_execute(): ORA-01400: cannot insert NULL oracle.jdbc.OracleDatabaseException: ORA-01400: 不能插入 NULL - oracle.jdbc.OracleDatabaseException: ORA-01400: cannot insert NULL into ORA-01400 无法在一对一关系中插入 null 错误 - ORA-01400 cannot insert null error in one to one relationship Oracle-错误:'ORA-01400:无法将NULL插入 - Oracle - Error: 'ORA-01400: cannot insert NULL into 当没有NULL值时,Oracle中出现错误“ ORA-01400:无法将NULL插入…” - Getting error in Oracle “ORA-01400: cannot insert NULL into…” when there are no NULL values PL / SQL ORA-01400:使用CASE时无法将NULL插入 - PL/SQL ORA-01400: cannot insert NULL into when using CASE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM