Q
Problem solve Get help with specific problems with your technologies, process and projects.

Calculating number of columns

How do I calculate the number of columns in a table without using the "DESCRIBE tablename"?
For this one, you can use one of the catalog views, ALL_TAB_COLUMNS. Each row in this view represents a column of a table or view to which you have rights. To illustrate, we'll create a dummy table, and then select a count from the ALL_TAB_COLUMNS view.

 
create table "ATE"."DUMMY_TABLE"
( dummycol1 numeric(10),
  dummycol2 varchar(4),
  dummycol3 date
);

select count(*) 
  from all_tab_columns 
  where owner = 'ATE' 
    and table_name = 'DUMMY_TABLE';

Here is the result of the query.

  COUNT(*)
----------
         3

Dig Deeper on Oracle and SQL

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close