You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Python+cx_Oracle访问Oracle其他OWNER下的表报ORA-00942如何解决

问题描述

我所在公司的Oracle数据库将不同项目的数据划分给不同OWNER管理。使用Python + cx_Oracle可以正常列出根数据库下的所有表,相关示例如图:
示例图片1
示例图片2

我在cx_Oracle官方文档中未找到访问其他OWNER所属表的相关说明,同样的查询语句在Oracle SQL Developer中可以正常执行,但在Python中运行时就报错,报错截图如下:
报错截图1
报错截图2

注:ORA-00942: a tabela ou view não existe对应含义为ORA-00942: table or view does not exist(表或视图不存在)

原有代码
import cx_Oracle

try:
    connection = cx_Oracle.connect(
        user='SYSTEM',
        password='123456',
        dsn='localhost:1521/XEPDB1',
        encoding='UTF-8'
    )
    print(connection.version)

    c = connection.cursor()
    rows = c.execute("select con_id,name,open_mode,restricted,open_time from v$pdbs").fetchall()
    for row in rows:
        print(row)

except Exception as ex:
    print(ex)

数据库连接详情如下图:
连接信息截图

若有知晓解决方法的朋友麻烦帮忙解答,非常感谢。


内容的提问来源于stack exchange,提问作者Lucas Ribeiro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.04 06:48:05