且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在SQL Developer中创建表时收到错误ORA-00907

更新时间:2023-01-22 09:48:27

我假设您每次更改Publisher表中的Pname列时都试图确保更新Book记录,但是Oracle没有on update cascade.

I assume you're trying to ensure that the Book records are updated whenever you change the Pname column in the Publisher table, but Oracle has no on update cascade.

有关语法图,请参见此处 references子句的

See here for the syntax diagram of the references clause.

要更改Oracle中的主键,您有几个选择:

To change primary keys in Oracle, you have a few options:

  • 延迟约束(外部键),直到提交为止,然后在事务中更新父级和子级.

  • Defer the constraint (foreign key) check until commit, then update both parent and child within the transaction.

使用更新的详细信息创建 new 父级,然后更改所有子级,然后删除原始父级.当然,所有这些都是交易.

Create a new parent with the updated details then go change all the children, then delete the original parent. All in a transaction of course.

停止使用可变数据作为键. DBA花了很长时间才能说服我使用人工(代理)密钥,而不是真实的数据,但这是最终使我胜过的用例.使用人工密钥(无需更改)意味着该问题完全消失了.

Stop using mutable data as a key. It took a long time for DBAs to convince me that artificial (surrogate) keys should be used rather than true data, but this was the use case that finally won me over. Using an artificial key (that never has to change) means this problem disappears totally.