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

2021-12-30 00:00:00 sql oracle11g oracle

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

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

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

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

sqlplus  john/passwd

我如何列出给定用户创建的所有表,例如约翰?

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

推荐答案

这将获取JOHN"用户是所有者的所有表:

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

SELECT * FROM USER_TABLES;

SELECT * FROM ALL_TABLES WHERE OWNER = 'JOHN';

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

([TL;DR] 'JOHN' typically needs to be in upper-case. Assuming that the user john was 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).)

相关文章