Home » RDBMS Server » Server Administration » List the Desc of all database tables in the Schema
List the Desc of all database tables in the Schema [message #371811] Sat, 09 December 2000 12:46 Go to next message
Kapil Chourasiya
Messages: 3
Registered: December 2000
Junior Member
Hi

I want to prepare a list which will contain the description of all the tables in my schema.
The Desc should atleast give me the following things::
Table Name
Column Name DataType Precision

Could anyone help me in this.

Thanks
-Kaycee
Re: List the Desc of all database tables in the Schema [message #371814 is a reply to message #371811] Sat, 09 December 2000 22:22 Go to previous messageGo to next message
SQL_Tuner
Messages: 8
Registered: November 2000
Junior Member
Here it is:

break on table_name;

select Table_name, column_name, data_type, data_length
from all_tab_columns
where owner = '<schema_name>'
order by 1, column_sequence;

I don't have Oracle at this terminal, so double check the names of the columns for the dictionary
table ALL_TAB_COLUMNS. I might not have the names quite right. In particular, one of the columns has the sequence number that shows the right order of the columns in the table.

You can get these names with:

DESC ALL_TAB_COLUMNS;

Good luck!

Regards,
ST
Updated: List the Desc of all database tables in the Schema [message #371831 is a reply to message #371811] Tue, 12 December 2000 09:23 Go to previous messageGo to next message
Shanthi Ramayanapu
Messages: 22
Registered: October 2000
Junior Member
SQL Tuner answer will only fetch you the column name, datatype with precision. If you also want to see the nullable option which is visible thru desc command, include nullable in his query
OR
try the following at sql prompt
set heading off
spool filename.sql
select 'desc '||table_name from user_tables;
spool off
edit filename and delete the last line (Should only have the desc commands with tablesname)
@filename

when you run the above you get what you need.

Shanthi
Re: Updated: List the Desc of all database tables in the Schema [message #371838 is a reply to message #371811] Tue, 12 December 2000 13:41 Go to previous message
SQL_Tuner
Messages: 8
Registered: November 2000
Junior Member
Yes, add the nuallable column if you need it. There are some other items there you can explore.

Using 'desc' is an inferior method. Each time you use it, you have to recreate the script. Also, it is only for user_tables as described above. You would need to modify it for tables in other schemas. Using ALL_TAB_COLUMNS is more flexible, and can be completely parameter driven.

Regards,
ST
Previous Topic: Re: mailing through oracle
Next Topic: How to handle the user-defined exception?
Goto Forum:
  


Current Time: Wed May 01 21:07:20 CDT 2024