mysql查询字段
查询表所有列
只要字段名
多行展示:
SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE table_name ="表名" AND table_schema = "库名" ORDER BY ORDINAL_POSITION;
例:
SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE table_name ="user" AND table_schema = "hlm" ORDER BY ORDINAL_POSITION;
结果:

单行展示:
SELECT group_concat("",COLUMN_NAME,"" ORDER BY ORDINAL_POSITION) cccc FROM information_schema.COLUMNS WHERE table_name ="表名" AND table_schema = "库名";
例:
SELECT group_concat("",COLUMN_NAME,"" ORDER BY ORDINAL_POSITION) cccc FROM information_schema.COLUMNS WHERE table_name ="user" AND table_schema = "hlm";
结果

详细信息
字段信息
show full COLUMNS FROM 库名.表名;
结果

建表语句
SHOW CREATE TABLE 库名.表名;
结果


浙公网安备 33010602011771号