SQL 列出 Oracle 中给定用户的所有表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38328258/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 04:42:28  来源:igfitidea点击:

List all tables of a given user in Oracle

sqloracleoracle11g

提问by m.r226

I am new to Oracle and want to find all tables created by user 'john' .

我是 Oracle 的新手,想查找用户 'john' 创建的所有表。

I connect to Oracle database via command line by the following command:

我通过以下命令通过命令行连接到 Oracle 数据库:

sqlplus  john/passwd

How do i list all the tables created by a given user e.g. john?

如何列出给定用户(例如 john)创建的所有表?

回答by MT0

This will get all the tables where the "JOHN" user is the owner:

这将获得“JOHN”用户是所有者的所有表:

SELECT * FROM USER_TABLES;

or

或者

SELECT * FROM ALL_TABLES WHERE OWNER = 'JOHN';

([TL;DR] 'JOHN'typically needs to be in upper-case. Assuming that the user johnwas created using the CREATE USER john ...statement then Oracle's default behaviour is to convert all object names (i.e. tables, columns, users, etc) to upper case. When you query the data-dictionary the table details will be stored in this case (and not the case you used in the original command unless you wrap it in double quotes).)

([TL;DR]'JOHN'通常需要大写。假设用户john是使用该CREATE USER john ...语句创建的,那么 Oracle 的默认行为是将所有对象名称(即表、列、用户等)转换为大写。当您查询数据字典,表详细信息将在这种情况下存储(而不是您在原始命令中使用的情况,除非您将其用双引号括起来)。)

回答by Sachu

To list the table you can use

要列出您可以使用的表格

SELECT * FROM ALL_TABLES WHERE OWNER = 'JOHN';

TO see the size of the schema you can use

查看您可以使用的架构的大小

SELECT sum(bytes)
  FROM dba_segments
 WHERE owner = 'JOHN'

Since you are logged in as the schema owner, you can also use

由于您以架构所有者身份登录,因此您还可以使用

SELECT SUM(bytes)
  FROM user_segments

回答by scaisEdge

You can use also

你也可以使用

select * from 
USER_TABLES;

anyway you can find all the data dictionary explain here https://docs.oracle.com/cd/B28359_01/server.111/b28310/tables014.htm

无论如何你可以在这里找到所有数据字典的解释https://docs.oracle.com/cd/B28359_01/server.111/b28310/tables014.htm

回答by imtiaj sreejon

select * from 
USER_TABLES;

The above code will show all the information of the tables under the user which is currently connected. This might be cluttered in your SQL terminal

上面的代码将显示当前连接的用户下的表的所有信息。这可能会在您的 SQL 终端中杂乱无章

To Specifically see only the table names under a user you should use the following code

要专门查看用户下的表名,您应该使用以下代码

select table_name 
from USER_TABLES;

回答by Francesco Serra

Try:

尝试:

select *
from all_tables
where owner = 'jhon';