如何查询Oracle数据库以显示Oracle数据库中所有表的名称?


当前回答

Oracle数据库显示所有表的名称使用下面的查询

SELECT owner, table_name FROM dba_tables;

SELECT owner, table_name FROM all_tables;

SELECT table_name FROM user_tables;

访问更多信息:http://www.plsqlinformation.com/2016/08/get-list-of-all-tables-in-oracle.html

其他回答

下面是一个注释的SQL查询片段,描述了如何使用选项:

-- need to have select catalog role
SELECT * FROM dba_tables;

-- to see tables of your schema
SELECT * FROM user_tables;

-- tables inside your schema and tables of other schema which you possess select grants on
SELECT * FROM all_tables;

查询user_tables和dba_tables无效。 这一个做到了:

select table_name from all_tables  

Oracle数据库显示所有表的名称使用下面的查询

SELECT owner, table_name FROM dba_tables;

SELECT owner, table_name FROM all_tables;

SELECT table_name FROM user_tables;

访问更多信息:http://www.plsqlinformation.com/2016/08/get-list-of-all-tables-in-oracle.html

下面的查询只列出了所需的数据,而其他的答案给了我额外的数据,这只会让我感到困惑。

select table_name from user_tables;

您可以使用Oracle数据字典来获取Oracle对象的信息。

你可以通过不同的方式获取表列表:

select * 
from dba_tables

或者举个例子:

select * 
from dba_objects 
where object_type = 'TABLE' 

然后你可以使用表名获取表列:

select * 
from dba_tab_columns

然后你可以得到依赖项列表(触发器,视图等):

select * 
from dba_dependencies
where referenced_type='TABLE' and referenced_name=:t_name 

然后你可以得到这个对象的文本源:

select * from dba_source

如果您愿意,可以使用USER或ALL视图而不是DBA视图。