Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all tables of a given user in Oracle

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

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?

like image 905
m.r226 Avatar asked Jul 12 '16 11:07

m.r226


People also ask

How can I see all tables in user?

SELECT table_name FROM user_tables; This query returns the following list of tables that contain all the tables owned by the user in the entire database.

How do you get all the tables for a particular schema in Oracle?

For a list of tables in the current schema, use the Show Tables command. For a list of views in the current schema, use the Show Views command. For a list of available schemas, use the Show Schemas command. If the table or view is in a particular schema, qualify it with the schema name.


3 Answers

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

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 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).)

like image 86
MT0 Avatar answered Oct 16 '22 18:10

MT0


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
like image 3
Sachu Avatar answered Oct 16 '22 18:10

Sachu


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

like image 1
ScaisEdge Avatar answered Oct 16 '22 19:10

ScaisEdge