……

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;
结果:
image

单行展示:

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";
结果
image

详细信息

字段信息

show full COLUMNS FROM 库名.表名;
结果
image

建表语句

SHOW CREATE TABLE 库名.表名;
结果
image

posted @ 2022-12-12 16:34  想做大佬的小明  阅读(174)  评论(0)    收藏  举报