Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number of columns in a table

Status
Not open for further replies.

beginnerboy

Technical User
Apr 15, 2004
7
CA
Hi

I have a requirement for my front end that I should create text boxes based on the number of columns . How can I get number of columns of a table if I know the table name? or how can I query to retrieve number of columns of a table?

thanks in advance
 
thanks Dima,
I got it the query should be like this
select count(*) from user_tab_columns group by table_name having table_name=<table_name>

best regards
Niran
 
beginnerboy -

You don't need to use the GROUP BY in your query since you don't have any non-aggregate terms in your select list. By adding the GROUP BY, you are inducing an unnecessary sort in your query. Dima's query will give you what you want with less overhead.

Also, USER_TAB_COLUMNS will only show the tables/columns that are in your current schema. ALL_TAB_COLUMNS will show you all tables/columns that are available to your schema.

Elbert, CO
0840 MDT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top