当前位置: 代码迷 >> 综合 >> Python 技术篇-操作oracle数据库执行SQL语句报错,提示ORA-00911: 无效字符解决方法
  详细解决方案

Python 技术篇-操作oracle数据库执行SQL语句报错,提示ORA-00911: 无效字符解决方法

热度:64   发布时间:2023-12-12 05:45:01.0

cursor.execute("select name from v$datafile;") 执行 sql 语句提示无效字符。
原因就是我加入了 ; 号。
改成 cursor.execute("select name from v$datafile") 就好了。
问题源码如下:

import cx_Oracle as cxcon = cx.connect('ncc2020_0609', 'sys', '10.10.xx.xx:1521/orcl')   # 创建连接
cursor = con.cursor()   # 创建游标
cursor.execute("select name from v$datafile;")   # 执行sql语句
for i in cursor:   # 打印数据print(i)
cursor.close()   # 关闭游标
con.close()   # 关闭数据库连接

报错信息:
在这里插入图片描述
修改后运行效果图:
在这里插入图片描述
喜欢的点个赞?吧!

  相关解决方案