快速解决 Error 45 initializing SQL*Plus 错误

本文介绍了解决使用sqlplus后台运行SQL脚本时出现的Error45问题的方法。作者分享了一个具体的PL/SQL文件示例,并给出了正确的命令行执行方式及脚本格式要求。
部署运行你感兴趣的模型镜像

最近,经常碰到使用sqlplus在后台运行sql脚本的情况,于是就遭遇了 Error 45 initializing SQL*Plus错误.

 

我运行的PL/SQL 文件 test.sql 如下

set serveroutput on;
set timing on;
DECLARE

BEGIN
  dbms_output.put_line(TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS'));
END;

该SQL文件所运行的Home folder所在磁盘的文件系统为 ext4. 关于文件类型,可以通过查看 /etc/fstab 文件确认.


后台运行sql 文件的命令如下

nohup sqlplus iqm_blk/welcome1@IQMDEV @test.sql > test.out 2>&1 &


我这里总结一下错误的主要原因

  •   test.sql 文件END;后不能有空行
  •   test.sql文件END;后,需要加入 /
  •   需要在/后加入exit; 命令. 当加入了exit; 后, 空行是没问题的.

能正确执行的脚本如下

set serveroutput on;
set timing on;
DECLARE

BEGIN
  dbms_output.put_line(TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS'));
END;
/
exit;

希望对大家有帮助。

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

2025-06-06 21:18:24 - Initializing Spring DispatcherServlet 'dispatcherServlet' 2025-06-06 21:18:24 - Initializing Servlet 'dispatcherServlet' 2025-06-06 21:18:24 - Detected StandardServletMultipartResolver 2025-06-06 21:18:24 - Detected AcceptHeaderLocaleResolver 2025-06-06 21:18:24 - Detected FixedThemeResolver 2025-06-06 21:18:24 - Detected org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator@47a99e2e 2025-06-06 21:18:24 - Detected org.springframework.web.servlet.support.SessionFlashMapManager@4f67f6b3 2025-06-06 21:18:24 - enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data 2025-06-06 21:18:24 - Completed initialization in 1 ms 2025-06-06 21:18:24 - GET "/product/list", parameters={} 2025-06-06 21:18:24 - Mapped to com.ecommerce.controller.ProductController#productList(Model) 2025-06-06 21:18:24 - {dataSource-1} inited 2025-06-06 21:18:24 - ==> Preparing: SELECT id, name, description, price, stock, category, image_url, create_time, update_time FROM goods 2025-06-06 21:18:24 - ==> Parameters: 2025-06-06 21:18:24 - Using @ExceptionHandler com.ecommerce.exception.GlobalExceptionHandler#handleRuntimeException(RuntimeException, Model) 2025-06-06 21:18:24 - Resolved [org.springframework.jdbc.BadSqlGrammarException: <EOL><EOL>### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Unknown column 'update_time' in 'field list'<EOL><EOL>### The error may exist in file [E:\webapp - 副本\webapp - 副本\target\classes\mapper\ProductMapper.xml]<EOL><EOL>### The error may involve defaultParameterMap<EOL><EOL>### The error occurred while setting parameters<EOL><EOL>### SQL: SELECT id, name, description, price, stock, category, image_url, create_time, update_time FROM goods<EOL><EOL>### Cause: java.sql.SQLSyntaxErrorException: Unknown column 'update_time' in 'field list'<EOL>; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'update_time' in 'field list'] to ModelAndView [view="error"; model={error=操作错误: ### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Unknown column 'update_time' in 'field list' ### The error may exist in file [E:\webapp - 副本\webapp - 副本\target\classes\mapper\ProductMapper.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: SELECT id, name, description, price, stock, category, image_url, create_time, update_time FROM goods ### Cause: java.sql.SQLSyntaxErrorException: Unknown column 'update_time' in 'field list' ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'update_time' in 'field list'}] 2025-06-06 21:18:24 - Using resolved error view: ModelAndView [view="error"; model={error=操作错误: ### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Unknown column 'update_time' in 'field list' ### The error may exist in file [E:\webapp - 副本\webapp - 副本\target\classes\mapper\ProductMapper.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: SELECT id, name, description, price, stock, category, image_url, create_time, update_time FROM goods ### Cause: java.sql.SQLSyntaxErrorException: Unknown column 'update_time' in 'field list' ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'update_time' in 'field list'}] 2025-06-06 21:18:25 - Completed 200 OK这是为什么
06-07
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值