SQL Error: ORA-00933: SQL command not properly ended(SQL 错误:ORA-00933:SQL 命令未正确结束)
问题描述
我正在尝试使用联接更新 oracle SQL 开发人员中的记录.以下是我的查询-
I am trying to update a record in oracle SQL developer by using Joins. Following is my query-
UPDATE system_info set field_value = 'NewValue'
FROM system_users users
JOIN system_info info ON users.role_type = info.field_desc
where users.user_name = 'uname'
但是,当我尝试执行它时,出现以下错误-
However, when I tried to execute it, I got following error-
Error report: SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
我尝试删除 JOINS
I tried removing JOINS
UPDATE system_info info
SET info.field_value = 'NewValue'
FROM system_users users
where users.user_name = 'uname' AND users.role_type = info.field_desc
但仍然有同样的错误谁能告诉我错误原因和解决方法
but still having same error can anybody tell me the error reason and solution
推荐答案
Oracle 不允许在 UPDATE 语句中连接表.你需要用一个相关的子选择重写你的语句
Oracle does not allow joining tables in an UPDATE statement. You need to rewrite your statement with a co-related sub-select
像这样:
UPDATE system_info
SET field_value = 'NewValue'
WHERE field_desc IN (SELECT role_type
FROM system_users
WHERE user_name = 'uname')
有关 UPDATE 语句的(有效)语法的完整说明,请阅读手册:
For a complete description on the (valid) syntax of the UPDATE statement, please read the manual:
http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10008.htm#i2067715
这篇关于SQL 错误:ORA-00933:SQL 命令未正确结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL 错误:ORA-00933:SQL 命令未正确结束


- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- SQL 临时表问题 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01