如何获得mysql数据库的所有的列

命令行下直接用:descrbe 表名

hive也是一样的。

用查询:

SELECT  COLUMN_NAME FROM  `information_schema`.`COLUMNS` where  `TABLE_NAME`='appStats' order by COLUMN_NAME

所有字段获取:
SELECT COLUMN_NAME FROM 'information_schema'.'COLUMNS' where 'TABLE_SCHEMA'='数据库名称' and 'TABLE_NAME'='你的表名' order by COLUMN_NAME;
或者

 select * from ’information_schema‘.’columns‘ where ’table_name‘='表名‘;


笨方法:
单个获取
$re_name_1=mysql_field_name($result,1);
$re_name_2=mysql_field_name($result,2);

原文地址:https://www.cnblogs.com/cl1024cl/p/6205664.html