Home » SQL & PL/SQL » SQL & PL/SQL » Number of columns in a table
Number of columns in a table [message #322563] Sat, 24 May 2008 08:58 Go to next message
srini_thiru
Messages: 133
Registered: May 2008
Senior Member


HI,

I am new to ORACLE.
I like to know the number of columns in a table. To find the number of rows in a table i have used

select count(*) from table_name;

I hope that some one can help me.

Thanks in Advance,

Seenu
Re: Number of columns in a table [message #322569 is a reply to message #322563] Sat, 24 May 2008 09:18 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
panyam was able to find himself the answer in a quarter of an hour to this question he also asked 3 hours before you.
Can you do it or can you find his post?

Regards
Michel
Re: Number of columns in a table [message #322575 is a reply to message #322563] Sat, 24 May 2008 09:31 Go to previous messageGo to next message
BlackSwan
Messages: 25035
Registered: January 2009
Location: SoCal
Senior Member
>select count(*) from table_name;
Do you really, really have a table named "table_name"?
Previously I thought that
select count(*) from table_name;
returned the number of rows; not the number of columns.
I am glad you corrected my erroneous thought.
Re: Number of columns in a table [message #322755 is a reply to message #322575] Mon, 26 May 2008 02:43 Go to previous messageGo to next message
srini_thiru
Messages: 133
Registered: May 2008
Senior Member

HI to all,

table_name is just an example for table name.

I like to know

How to calculate the number of columns in a table by using query.


thanks,

Seenu
Re: Number of columns in a table [message #322758 is a reply to message #322563] Mon, 26 May 2008 02:57 Go to previous messageGo to next message
mm_kanish05
Messages: 487
Registered: January 2007
Location: Chennai
Senior Member

hi


     select count(*) from user_tab_columns where table_name = 'YOURTABLENAME'



kanish
Re: Number of columns in a table [message #323171 is a reply to message #322758] Tue, 27 May 2008 09:38 Go to previous messageGo to next message
srini_thiru
Messages: 133
Registered: May 2008
Senior Member

I got it.

Thank u

Seenu
Re: Number of columns in a table [message #323196 is a reply to message #322758] Tue, 27 May 2008 12:25 Go to previous message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
Although you do have the answer to your question, what is the business reason that one would need to know the number of columns in a table? This is a serious question.
Previous Topic: Performant Locking of Multiple Rows with FOR UPDATE
Next Topic: I have problem with creation for View !!!
Goto Forum:
  


Current Time: Sat Dec 03 20:12:07 CST 2016

Total time taken to generate the page: 0.08703 seconds