如何获取列名列表 [英] How to get a list of column names

查看:28
本文介绍了如何获取列名列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以像这样获取包含表的所有列名的行?

Is it possible to get a row with all column names of a table like this?

|id|foo|bar|age|street|address|

我不喜欢使用Pragma table_info(bla).

推荐答案

SELECT sql FROM sqlite_master
WHERE tbl_name = 'table_name' AND type = 'table'

然后用 Reg Exp 解析这个值(这很容易),它看起来类似于:[(.*?)]

Then parse this value with Reg Exp (it's easy) which could looks similar to this: [(.*?)]

或者您可以使用:

PRAGMA table_info(table_name)

这篇关于如何获取列名列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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