ORA-00933: SQL 命令未正确结束 00933. 00000 - “SQL 命令未正确结束
Posted
技术标签:
【中文标题】ORA-00933: SQL 命令未正确结束 00933. 00000 - “SQL 命令未正确结束【英文标题】:ORA-00933: SQL command not properly ended 00933. 00000 - "SQL command not properly ended 【发布时间】:2019-11-10 19:46:31 【问题描述】:Select S.sname
From suppliers s
where not exists (
(select * from parts p where p.color = 'red') ; all red parts
except
(select c.pid from catalog c, parts p where c.sid = s.sid
and c.pid = p.pid and p.color = 'red'))
select p.pname
from parts p. catalog c, suppliers s
where p.pid = c.pid and c.sid = s.sid
AND s.sname = 'S1'
AND not exists ( # another supplier
select * from catalog c1, suppliers s1
where p.pid = c1.pid and c1.sid = s1.sid
AND s1.sname <> 'S1')
当我执行上述两个查询时,它显示 SQL 命令未正确结束
【问题讨论】:
你需要用;
终止每条语句(加上嵌入的; all red parts
和`#另一个供应商`也是错误的
Oracle 的 SQL 中没有例外。注释掉由两个破折号(--
)执行,仅一行,/* */
执行多行,但不是#
或;
【参考方案1】:
可能是因为它们无效;那些是什么
; all red parts except
和
# another supplier
应该怎么做?评论,也许?在 Oracle 中,您可以使用 --
或将 cmets 包含在 /* ... */
中。
这可能更好一些:
第一个查询:
Select S.sname
From suppliers s
where not exists ( (select *
from parts p
where p.color = 'red'
)
minus
(select c.pid
from catalog c, parts p
where c.sid = s.sid
and c.pid = p.pid
and p.color = 'red'
)
);
第二次查询:
select p.pname
from parts p, catalog c, suppliers s
where p.pid = c.pid
and c.sid = s.sid
AND s.sname = 'S1'
AND not exists (select *
from catalog c1, suppliers s1
where p.pid = c1.pid
and c1.sid = s1.sid
AND s1.sname <> 'S1'
);
【讨论】:
以上是关于ORA-00933: SQL 命令未正确结束 00933. 00000 - “SQL 命令未正确结束的主要内容,如果未能解决你的问题,请参考以下文章
为啥会出现“ORA-00933:SQL 命令未正确结束”错误(立即执行)?