MySql:显示列,但排除除字段名称以外的所有内容 [英] MySql: Show columns but exclude everything except the field names

查看:314
本文介绍了MySql:显示列,但排除除字段名称以外的所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将表的字段名称从MySql中提取到python中,我知道

I'd like to pull a table's field names from MySql into python, and I know that

'show columns from project'

将起作用.并且我读到您可以添加"WHERE ..."以将其限制为仅某些字段.但是我找不到如何仅返回列名而不返回类型,键,空值和附加信息的示例.

will work. And I've read that you can add 'WHERE ...' to restrict it to just certain fields. But I can't find an example of how to return just the names of the columns, and not Type, Key, Null, Extra information.

什么是匹配条件以提取列的所有字段名称,而没有其他描述内容?

What is the matching criteria to pull all field names for columns and none of the other description stuff?

推荐答案

SELECT column_name
FROM information_schema.columns
WHERE  table_name = 'your_table'
   AND table_schema = 'database_name'

这篇关于MySql:显示列,但排除除字段名称以外的所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆