如何在 Oracle SQL 中列出模式中的所有表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2247310/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I list all tables in a schema in Oracle SQL?
提问by benstpierre
How do i list all tables in a schema in Oracle SQL?
如何在 Oracle SQL 中列出模式中的所有表?
回答by Adam Musch
To see all tables in another schema, you need to have one or more of the following system privileges:
要查看另一个架构中的所有表,您需要具有以下一项或多项系统权限:
SELECT ANY DICTIONARY
(SELECT | INSERT | UPDATE | DELETE) ANY TABLE
or the big-hammer, the DBA role.
或者大锤,DBA 角色。
With any of those, you can select:
对于其中任何一个,您可以选择:
SELECT DISTINCT OWNER, OBJECT_NAME
FROM DBA_OBJECTS
WHERE OBJECT_TYPE = 'TABLE'
AND OWNER = '[some other schema]'
Without those system privileges, you can only see tables you have been granted some level of access to, whether directly or through a role.
如果没有这些系统权限,您只能查看已被授予某种级别访问权限的表,无论是直接访问还是通过角色访问。
SELECT DISTINCT OWNER, OBJECT_NAME
FROM ALL_OBJECTS
WHERE OBJECT_TYPE = 'TABLE'
AND OWNER = '[some other schema]'
Lastly, you can always query the data dictionary for your own tables, as your rights to your tables cannot be revoked (as of 10g):
最后,您始终可以查询自己表的数据字典,因为您对表的权限无法撤销(从 10g 开始):
SELECT DISTINCT OBJECT_NAME
FROM USER_OBJECTS
WHERE OBJECT_TYPE = 'TABLE'
回答by Tom
SELECT table_name from all_tables where owner = 'YOURSCHEMA';
回答by Sathyajith Bhat
You can query USER_TABLES
你可以查询 USER_TABLES
select TABLE_NAME from user_tables
回答by chan
If you logged in as Normal User without DBA permission you may uses the following command to see your own schema's all tables and views.
如果您在没有 DBA 权限的情况下以普通用户身份登录,您可以使用以下命令查看您自己的架构的所有表和视图。
select * from tab;
回答by SQLMenace
Try this, replace ? with your schema name
试试这个,更换?使用您的架构名称
select TABLE_NAME from INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA =?
AND TABLE_TYPE = 'BASE TABLE'
回答by Arsalan Sheikh
select * from cat;
it will show all tables in your schema cat synonym of user_catalog
它将显示 user_catalog 的模式 cat 同义词中的所有表
回答by A A Nayak
select TABLE_NAME from user_tables;
Above query will give you the names of all tables present in that user;
以上查询将为您提供该用户中存在的所有表的名称;
回答by yash
select * from user_tables;
(showing all tables)
(显示所有表格)
回答by Pablo Santa Cruz
If you are accessing Oracle with JDBC (Java) you can use DatabaseMetadataclass. If you are accessing Oracle with ADO.NET you can use a similar approach.
如果您使用 JDBC (Java) 访问 Oracle,则可以使用DatabaseMetadata类。如果您使用 ADO.NET 访问 Oracle,您可以使用类似的方法。
If you are accessing Oracle with ODBC, you can use SQLTablesfunction.
如果您使用 ODBC 访问 Oracle,则可以使用SQLTables函数。
Otherwise, if you just need the information in SQLPlus or similar Oracle client, one of the queries already mentioned will do. For instance:
否则,如果您只需要 SQLPlus 或类似 Oracle 客户端中的信息,则可以使用已经提到的查询之一。例如:
select TABLE_NAME from user_tables
回答by Sreeju
SELECT table_name, owner FROM all_tables where owner='schema_name' order by table_name
SELECT table_name, owner FROM all_tables where owner='schema_name' order by table_name