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


当前回答

尝试从user_tables中选择,其中列出了当前用户拥有的表。

其他回答

包括视图:

SELECT owner, table_name as table_view
  FROM dba_tables
UNION ALL
SELECT owner, view_name as table_view
  FROM DBA_VIEWS

为了更好地使用sqlplus查看

如果您正在使用sqlplus,您可能希望首先设置一些参数以更好地查看您的列(这些变量不应该在退出sqlplus会话后继续存在):

set colsep '|'
set linesize 167
set pagesize 30
set pagesize 1000

显示所有表格

然后你可以使用类似这样的东西来查看所有表名:

SELECT table_name, owner, tablespace_name FROM all_tables;

展示你拥有的桌子

正如@Justin Cave提到的,你可以用它来显示你拥有的表:

SELECT table_name FROM user_tables;

不要忘记视图

请记住,一些“表”可能实际上是“视图”,所以你也可以尝试运行类似的程序:

SELECT view_name FROM all_views;

结果

这应该会产生一些看起来相当可以接受的东西,比如:

下面是一个注释的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;

试试下面的数据字典视图。

tabs
dba_tables
all_tables
user_tables
    select object_name from user_objects where object_type='TABLE';

---------------- 或 ------------------

    select * from tab;

---------------- 或 ------------------

    select table_name from user_tables;