oracle - 从 oracle 数据库服务器中提取表名
问题描述
我可以访问一个连接到商店的 oracle11g 服务器,并且有一个软件可以在 softare 中获取报告,但该软件是封闭源代码的。因为我在数据库中有一个用户名,我可以从软件访问所有报告,但我想自动化一些工作并想编写一个 python3 脚本来做到这一点。我只需要知道 DB 中的表名。我想要一个在 oracle 中返回表名的代码。我可以从“PLSQL Developer”和我未完成的 python 代码访问数据库。
import cx_Oracle
con = cx_Oracle.connect('username/password@serveraddress/dbname')
print (con.version)
cur =con.cursor()
cur.execute(" SOME ORACLE CODE")
#cur.execute('select * from tablesname orderby id' )
for i in cur:
print (i)
con.close()
那么什么是可以执行并将表名返回给我的代码?
ps:我什至用wireshark找出程序发送到服务器的代码是什么,但数据包中没有表名。:(
ps 2:欢迎任何有创意和不寻常的答案。
解决方案
您可以使用
select table_name
from user_tables
order by table_name
或者
select table_name
from cat
where table_type = 'TABLE'
order by table_name
派生当前用户中所有表的名称。wherecat
是user_catalog
数据字典视图的同义词,user_tables
是数据库在安装过程中自动创建的另一个数据字典视图。
推荐阅读
- powershell - 使用 Read-Host 时有什么方法可以避免换行吗?
- c# - 有没有办法在反应式 ui 中使用异步值转换器?
- mysql - 如何获取字段的位置?(MYSQL)
- oracle - Oracle 复制可能性
- javascript - React JS 渲染错误的列表和键
- google-cloud-platform - 限制 gsutil -m 线程
- json - 如何编辑 JSON 结构
- c# - MvcOptions.SuppressImplicitRequiredAttributeForNonNullableReferenceTypes 到底发生了什么变化?
- c# - 正确理解异步/等待。它是如何正确的?
- c# - Xamarin,使用 x:name 找不到另一个按钮