MySQL有多少列表有

MySQL有多少列表有

This question already has answers here:
Find the number of columns in a table
                                
                                    (19个回答)
                                
                        
                                6年前关闭。
            
                    
我有桌子:

SHOW COLUMNS FROM `darbuotojai`;
+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id           | int(10)      | NO   | PRI | NULL    | auto_increment |
| vardas       | char(20)     | YES  |     | NULL    |                |
| pavarde      | char(30)     | YES  |     | NULL    |                |
| email        | char(100)    | YES  |     | NULL    |                |
| pareigos     | char(50)     | YES  |     | NULL    |                |
| ilg_tel_nr   | decimal(8,0) | NO   | PRI | 0       |                |
| trump_tel_nr | decimal(3,0) | NO   | PRI | 0       |                |
| inv_nr       | char(10)     | YES  |     | NULL    |                |
+--------------+--------------+------+-----+---------+----------------+


如何使用sql命令计数表中的列?
以及我如何识别它们?

最佳答案

SELECT count(*)
FROM information_schema.columns
WHERE table_name = 'darbuotojai'

关于c# - MySQL有多少列表有,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16706510/

10-12 16:26