如何在 Oracle 11g 中使用 SQL Developer 进行删除级联?
我正在尝试从数据库中的一个表中删除一条记录,但另一个表引用了该行(外键)。所以我想使用Oracle 11g中的SQL Developer进行删除级联。我该怎么做?
I am trying to delete a record from one table in my db, but another table has references to this row (foreign keys). So I want to make on delete cascade using SQL Developer in Oracle 11g. How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
回答OP的技术问题:
在 SQL Developer 中,您可以使用外键引用编辑(子)表。从左侧的树视图中选择“约束”,然后选择有问题的外键。在“引用约束”表单中,有一个名为“删除时”的下拉菜单。从该下拉列表中选择“级联”。
To answer the OP's technical question:
In SQL Developer, you edit the (child) table with the foreign key reference. Select "Constraints" from the treeview on the left and then select the foreign key in question. In the "Referenced Constraint" form there is a drop down named "On Delete". From that drop down, choose "Cascade".
如果您尝试删除(父)表中的行,并且其他(子)表具有对其的外键引用,那么
每当删除父记录时,都会导致删除所有子行,您指定“ON DELETE级联”选项。
在这种情况下,如果从部门表中删除一行,则不会引发默认情况下的错误,而是删除员工表中的所有员工。
这与工具(SQL Developer)无关...
If you are trying to delete rows in a (parent) table and other (child) tables have foreign key references to it, then it will cause the
TO delete all the child rows whenever a parent record is removed, you specify the "ON DELETE CASCADE" option.
In this case , if a row from the department table is deleted, instead of raising an error which is the default case, it will delete all the employees form the employee table.
This has nothing to do with the tool (SQL Developer)...