How can I find out the number of columns a table has?
I use oracle 10g and I want to develop a J2EE application to count the number of columns of different tables.
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
That's what the system catalogs are for:
select count(*) from all_tab_columns where owner = 'SOME_USER' and table_name = 'SOME_TABLE';
To get it per table, use a `group by
select table_name, count(*) from all_tab_columns where owner = 'SOME_USER' group by table_name order by table_name;
More details about the system catalogs can be found in the manual: