如何使用c#获取oracle中的所有数据库名称? [英] How to get all database names in oracle using c# ?

查看:584
本文介绍了如何使用c#获取oracle中的所有数据库名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道它们是使用c#在oracle中获取所有数据库名称的任何方法.我的要求是在oracle中显示所有数据库名称.然后,我需要列出每个数据库中的所有表和过程.我知道如何在每个数据库中使用表.但是我不知道如何使用c#列出所有数据库名称.我正在使用oracle 9i服务器.

I like to know their is any way to get all database names in oracle using c#. My requirement is to display all database names in oracle. Then i need to list all tables, procedures in each database. I know how to take tables in each database. But i do not know how to list all database names using c#. I am using oracle 9i server.

推荐答案

首先,我假设您是指所有Schema,而不是数据库,毕竟这是oracle. />
要选择模式列表,您可以使用它.但是您需要具有有效的权限.
First, I''m assuming you mean all Schema''s, not databases, this is oracle after all.

To select a list of schema''s you can use this. But you need to have valid permissions for it.
SELECT * FROM dba_users;



当然,并非所有模式都有表,因此另一种方法是使用此



Of course not all schema''s have tables so another way is to use this

SELECT owner, table_name FROM dba_tables;



这将为您提供该架构的模式"和所有表名.

您可以使用类似的调用来获取过程,函数,包以及列名称,数据类型和大小.所有这些数据都存储在系统表中.



which will give you the ''schema'' and all the table names for that schema.

you can use similar calls to get the procedures, functions, Packages and the column names, datatypes and sizes as well. All that data is stored in system tables.

SELECT Owner, Object_Name, Object_type, Status FROM ALL_OBJECTS WHERE OBJECT_TYPE IN ('FUNCTION','PROCEDURE','PACKAGE');


为什么不使用Tnsnames.ora文件并读取它以识别其中的实例列表?
您可以在oracle_home/network/admin下找到它,或者您的团队可能正在从共享文件夹中使用它.

请参考下面的链接,作为使用tns条目的单个数据库连接的示例.

http://www.oracle.com/technetwork/articles/dotnet/cook-dotnet- 101788.html [ ^ ]
Why shouldn''t you use Tnsnames.ora file and read it to identify the list of instances inside it?
You can find it under oracle_home/network/admin or your team might be using it from the share folder.

Please refer the link below just an example for a single db connection using tns entries.

http://www.oracle.com/technetwork/articles/dotnet/cook-dotnet-101788.html[^]


这篇关于如何使用c#获取oracle中的所有数据库名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆