简体   繁体   English

使用SQL Developer探索Oracle数据库

[英]Explore Oracle Database using SQL Developer

I'm in a project which requires me to query a database and generate ad-hoc reports with the columns specified by the user. 我在一个项目中,需要我查询数据库并使用用户指定的列生成临时报告。

When I was working with DB2 on a different database with little documentation about the tables and columns available I could also use queries like the ones mentioned below to get what I was looking for 当我在不同的数据库上使用DB2时,几乎没有关于表和列的可用文档,我还可以使用下面提到的查询来获得我想要的东西

select * from syscat.procedures where procschema like 'ABCD' and text like '%your text%';
select * from syscat.columns where tabschema like 'ABCD' and colname like '%yourtext%';

In my new project, I'll be working with Oracle on a different database and this time I have no document which could tell me what information is in which column. 在我的新项目中,我将在不同的数据库上使用Oracle,这一次我没有文档可以告诉我哪一列中包含哪些信息。 Also, there is nobody in this project who could assist me with this. 另外,这个项目中没有人可以协助我。

Are there any such queries in Oracle like the ones I mentioned above from DB2 which could help me find what I need from the database? 在Oracle中是否有这样的查询,例如我上面从DB2提到的查询,可以帮助我从数据库中找到所需的信息?

Welcome to Oracle! 欢迎使用Oracle!

Since you tagged SQL Developer, I'll show you how to do what you want to do there. 自从您标记了SQL Developer之后,我将向您展示如何做您想做的事情。

But first, views of interest to you: 但是首先,您感兴趣的观点是:

  • ALL_TAB_COLUMNS ALL_TAB_COLUMNS
  • ALL_SOURCE ALL_SOURCE

But, to use the GUI to search these views... 但是,要使用GUI搜索这些视图...

You can use the reports to learn our data dictionary. 您可以使用报告来学习我们的数据字典。

在此处输入图片说明

A couple of different ways you could go, but here's an example, the Columns report. 您可以采用几种不同的方式,但是这里有一个例子,即“列”报告。

在此处输入图片说明

As you're browsing around, you can observe the statements panel in the Log section. 浏览时,您可以观察“日志”部分中的“语句”面板。 So you can see that we're querying 这样您就可以看到我们正在查询

在此处输入图片说明

By looking at the query that runs for this report, you can see we're hitting the following data dictionary views: 通过查看针对该报告运行的查询,您可以看到我们正在访问以下数据字典视图:

snippet of the SQL: SQL的代码段:

      owner         sdev_link_owner,
       table_name    sdev_link_name,
       'TABLE' sdev_link_type
   from sys.dba_tab_columns
  where (:owner is null
     or instr(
     owner,

DBA_TAB_COLUMNS ( Oracle Docs ) DBA_TAB_COLUMNS( Oracle文档

You'll note that there is both a DBA_TAB_COLUMNS and a ALL_TAB_COLUMNS. 您会注意到,既有DBA_TAB_COLUMNS,也有ALL_TAB_COLUMNS。 Only a 'superuser' can query the DBA_ views. 只有“超级用户”才能查询DBA_视图。 Anyone can look into ALL_ views, but you'll only be able to see the objects your database privileges grant access to. 任何人都可以查看ALL_视图,但是您只能看到数据库特权授予访问权限的对象。

There are also USER_ views - they show just the things you need to know about the schema for the user you are logged in as. 还有USER_视图-它们仅显示您作为登录用户所需要的关于架构的知识。 In Oracle, schema and user are basically the same thing. 在Oracle中,架构和用户基本上是同一件事。

So, try the reports, answer your questions. 因此,尝试报告,回答您的问题。 Inspect the SQL we're using, learn the data dictionary. 检查我们正在使用的SQL,学习数据字典。

You can also use our Search Feature - it's built for finding stuff in the database. 您还可以使用我们的搜索功能 -它是为在数据库中查找内容而构建的。

Good luck on your Oracle journey! 祝您在Oracle旅途中万事如意!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM