To get total number of columns in a table in sql

后端 未结 9 1321
清酒与你
清酒与你 2021-01-30 13:05

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

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-30 13:11

    Select Table_Name, Count(*) As ColumnCount
    From Information_Schema.Columns
    Group By Table_Name
    Order By Table_Name
    

    This code show a list of tables with a number of columns present in that table for a database.

    If you want to know the number of column for a particular table in a database then simply use where clause e.g. where Table_Name='name_your_table'

提交回复
热议问题