MySql教程

mysql、postgresql查询表字所有字段

本文主要是介绍mysql、postgresql查询表字所有字段,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1、mysql查询表字所有字段

SHOW FULL COLUMNS FROM table_name;

解释:

Field :字段名
Type:字段类型
Collation:字符集(mysql 5.0以上有)
Null :是否可以为NULL
Key:索引(PRI,unique,index)
Default:缺省值
Extra:额外(是否 auto_increment)
Privileges:权限
Comment:备注(mysql 5.0以上有)

2、postgresql查看表字段

SELECT a.attnum,
a.attname AS field,
t.typname AS type,
a.attlen AS length,
a.atttypmod AS lengthvar,
a.attnotnull AS notnull,
b.description AS comment
FROM pg_class c,
pg_attribute a
LEFT OUTER JOIN pg_description b ON a.attrelid=b.objoid AND a.attnum = b.objsubid,
pg_type t
WHERE c.relname = 't_uc_login'
and a.attnum > 0
and a.attrelid = c.oid
and a.atttypid = t.oid
ORDER BY a.attnum;
这篇关于mysql、postgresql查询表字所有字段的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!