Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To get total number of columns in a table in sql

Tags:

sql-server

I need a query in sql to get total columns in a table.Can anybody help?

like image 438
user42348 Avatar asked Sep 23 '09 09:09

user42348


People also ask

How do I count the number of columns in a table in SQL Developer?

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: ALL_TAB_COLUMNS.

How do I get all the columns in a table in SQL?

In a query editor, if you highlight the text of table name (ex dbo. MyTable) and hit ALT + F1 , you'll get a list of column names, type, length, etc.

How do I display the SUM of all columns in SQL?

The aggregate function SUM is ideal for computing the sum of a column's values. This function is used in a SELECT statement and takes the name of the column whose values you want to sum. If you do not specify any other columns in the SELECT statement, then the sum will be calculated for all records in the table.


1 Answers

SELECT COUNT(COLUMN_NAME)  FROM INFORMATION_SCHEMA.COLUMNS  WHERE TABLE_CATALOG = 'database' AND TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'table'      
like image 159
Vinko Vrsalovic Avatar answered Oct 18 '22 22:10

Vinko Vrsalovic