SQL Script to List Table Columns

Posted on 2008-06-19
Medium Priority
Last Modified: 2013-12-19
Recently purchased an ERP system that uses Oracle  The system includes a data dictionary and an interface to write SQL scripts.  I would like to write 2 SQL scripts:

1.  Script that lists all of the column/field names in a single table
2.  Script that lists all of the column/field names in all of the tables.

The scripts will then be used in Crystal Reports to assist me in finding columns(fields).

Question by:pcguru_gary
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 14

Expert Comment

ID: 21826423

--To list all columns for given table
WHERE TABLE_NAME = '<table_name>'
--to list all columns in all tables

Open in new window

LVL 101

Expert Comment

ID: 21827389
How do you plan to use them in a report?


Author Comment

ID: 21830505
ajexpert provided the script that works.  mlmcc asked an important follow up question: How do I plan to use them in a report?  Because the output from the SQL statement in Data Dictionary prints to screen only and cannot be exported, I need to create a formula in CR that can then be exported to Excel.  The table/column listing would then be easy to search on for specific column names.  

So the question is:  How do I create a CR from scratch using the script that ajexpert provided?  

Note: I increased the point value and will split them.

LVL 22

Accepted Solution

DrSQL earned 1500 total points
ID: 21831140
    If you have sqlplus as part of your ERP system, then you can "spool" the data to a file.  Also, you can search the dictionary,just like any other Oracle table.

To spool a file of all tables and all columns to which you have access:

set lines 2000
set pages 0
set heading on
set trimspool on
select * from all_tab_columns
spool tabledefs.txt
spool off

To search for a particular column in YOUR schema:
select table_name,column_name from user_tab_columns
where column_name like '%CREDIT%';

Here's a link to all of the views available to you: http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_part.htm#REFRN002

Good luck!
LVL 22

Expert Comment

ID: 22088396
    It's been over a month.  Could you please update/close this question?  Thank you for using Experts Exchange.

Good luck!

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question