How do I count columns of a table

后端 未结 8 1921
独厮守ぢ
独厮守ぢ 2020-11-30 02:43

For example :

tbl_ifo

id | name  | age | gender 
----------------------------
1  | John  |  15 |  Male
2  | Maria |  18 |  Female
3  | Steph |  19 |  Female         


        
8条回答
  •  自闭症患者
    2020-11-30 03:35

    To count the columns of your table precisely, you can get form information_schema.columns with passing your desired Database(Schema) Name and Table Name.


    Reference the following Code:

    SELECT count(*)
    FROM information_schema.columns
    WHERE table_schema = 'myDB'  
    AND table_name = 'table1';
    

提交回复
热议问题