Finding which columns contain data in a table
5 pts.
0
Q:
Finding which columns contain data in a table
I have to establish which columns in a table have data present.
Each row has up to 100 columns, and not all of the columns contain data relating to the row.

So in Table 1,
Col1 Col2 Col3 Col4
Row 1 abc
Row 2 abc
Row 3 abc

Would give a report showing that Table 1 has Columns Col1, Col2, Col4 being used.

Application.
We are moving from an Oracle database application to an SQL database application.
The data migration mapping cannot be field for field, and I need to know that the data we actually have in the Oracle data set has a placeholder in the SQL data set before the exercise is started.
ASKED: Dec 10 2008  3:42 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
29820 pts.
0
A:
 RATE THIS ANSWER
+1
Click to Vote:
  •   1
  •  0
  • AddThis Social Bookmark Button
The following query will give you that information for a specific table:

  select column_name,data_type,data_length,data_precision,nullable,column_id
from all_tab_columns atc, all_tables at
where atc.table_name = at.table_name
and atc.owner = at.owner
and at.owner = '&owner'
and at.table_name = '&table'
and atc.num_nulls < at.num_rows
order by atc.column_id;


(I tested it on Oracle 8i, thereby I could not use the ANSI join syntax)

I think you can achieve the same without joining the all_tables table, this way:

  select column_name,data_type,data_length,data_precision,nullable,column_id
from all_Tab_columns
where owner = '&owner'
and table_name = '&table'
and num_distinct != 0
order by column_id;


Please note that tables need to be analyzed in order to get accurate results.
Last Answered: Dec 10 2008  11:34 PM GMT by Carlosdl   29820 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



0