数据库
首页 > 数据库> > 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;

标签:5.0,postgresql,attnum,表字,pg,mysql,type
来源: https://www.cnblogs.com/zhaoxxnbsp/p/15715502.html