简体   繁体   English

Oracle SQL 开发人员 - 为什么我无法从我在删除级联上设置的表中删除行并收到无效的表名错误?

[英]Oracle SQL developer - why I cannot delete the row from the tables that I set on delete cascade and get an invalid table name error?

I'm using Oracle SQL Developer , below is the error I get:我正在使用Oracle SQL Developer ,下面是我得到的错误:

Error report - SQL Error: ORA-00903: invalid table name 00903. 00000 - "invalid table name"错误报告 - SQL 错误:ORA-00903:无效的表名 00903. 00000 - “无效的表名”

Here is my code:这是我的代码:

ALTER TABLE PCASE
  DROP CONSTRAINT PCASE_Participant_FK;

ALTER TABLE PCASE
  ADD CONSTRAINT PCASE_Participant_FK
  FOREIGN KEY ( PartID )
  REFERENCES Participant ( PartID )
  ON DELETE CASCADE;


ALTER TABLE Meeting
  DROP CONSTRAINT Meeting_PCASE_FK;

ALTER TABLE Meeting
  ADD CONSTRAINT Meeting_PCASE_FK
  FOREIGN KEY ( PCaseNo )
  REFERENCES PCASE ( PCaseNo )
  ON DELETE CASCADE; 


ALTER TABLE MPlan
  DROP CONSTRAINT MPlan_Meeting_FK;

ALTER TABLE MPlan
  ADD CONSTRAINT MPlan_Meeting_FK
  FOREIGN KEY ( PCaseNo, MeetingNo )
  REFERENCES Meeting ( PCaseNo, MeetingNo )
  ON DELETE CASCADE; 


ALTER TABLE Laboratory
  DROP CONSTRAINT Laboratory_MPlan_FK; 

ALTER TABLE Laboratory
  ADD CONSTRAINT Laboratory_MPlan_FK
  FOREIGN KEY ( MPlanNo )
  REFERENCES MPlan ( MPlanNo )
  ON DELETE CASCADE; 


ALTER TABLE Diary
  DROP CONSTRAINT Diary_MPlan_FK; 

ALTER TABLE Diary
  ADD CONSTRAINT Diary_MPlan_FK
  FOREIGN KEY ( MPlanNo )
  REFERENCES MPlan ( MPlanNo )
  ON DELETE CASCADE; 

COMMIT;

SELECT * 
  FROM Participant
  WHERE PartID=12345;

DELETE * 
  FROM Participant
  WHERE PartID=12345;

I just set the FKs of the child tables as ON DELETE CASCADE , but it does not work.我只是将子表的FKs设置为 ON DELETE CASCADE ,但它不起作用。 I tried another method as below, but get the same error.我尝试了下面的另一种方法,但得到了同样的错误。

DELETE *
FROM Participant p, PCASE pc, Meeting m, MPlan mp, Laboratory l
WHERE p.PartID=pc.PartID
AND pc.PCaseNo=m.PCaseNo
AND (m.PCaseNo=mp.PCaseNo
    AND m.MeetingNo=mp.MeetingNo)
AND mp.MPlanNo=l.MPlanNo 
AND p.PartID=12345;


DELETE *
FROM Participant p, PCASE pc, Meeting m, MPlan mp, Diary d
WHERE p.PartID=pc.PartID
AND pc.PCaseNo=m.PCaseNo
AND (m.PCaseNo=mp.PCaseNo
    AND m.MeetingNo=mp.MeetingNo)
AND mp.MPlanNo=d.MPlanNo
AND p.PartID=12345;

Can anybody help?有人可以帮忙吗? Thanks a lot!非常感谢!

It's DELETE FROM ... , not DELETE * FROM ... .它是DELETE FROM ... ,而不是DELETE * FROM ... Your invalid syntax is confusing Oracle's parser into giving you a slightly misleading error message.您的无效语法使 Oracle 的解析器感到困惑,从而为您提供了稍微误导性的错误消息。

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

相关问题 用于显示表是否在删除时设置为级联的SQL命令 - SQL command to show if table is set to cascade on delete 具有三个表的“关于删除级联”。 错误无法添加或更新子行 - “On delete cascade” with three tables. Error cannot add or update a child row 从表中删除行:“无法删除或更新父行:外键约束失败”是外键问题或CASCADE会完成这项工作吗? - Delete row from table:“Cannot delete or update a parent row:a foreign key constraint fails” is that a FOREIGN KEY problemm or CASCADE will do the job? SQL Server ON DELETE CASCADE错误 - SQL Server ON DELETE CASCADE Error 如果我有一个从属表并且知道第三个表中的值,则从一个表中删除行 - Delete row from one table if I have a dependent tables and know value in the third 如何从SQL中的乘法表中删除行? - How to Delete a Row from multiply tables in sql? Oracle:删除子表时删除父表(双向级联删除) - Oracle: delete parent table when child is deleted(Bidirectional Cascade Delete) 登录 oracle 帐户时出现错误,例如来自 sql 开发人员的“hr” - I get error when logging into oracle account such as 'hr' from sql developer 为什么不能从具有关系的表中删除它? - Why can't I delete this from my tables that have relationships? Laravel 中的 SQL Server ON DELETE CASCADE 错误 - SQL Server ON DELETE CASCADE Error In Laravel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM