如果数据库表结构发生变化,如果不方便直接查看数据表,通常需要通过SQL读出表结构。在postgresql数据库中此时的SQL语句应当如下:
SELECT a.attnum, a.attname AS field, t.typname AS type, a.attlen AS length, a.atttypmod AS lengthvar, a.attnotnull AS notnull
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname='reg_user' and a.attnum > 0 and a.attrelid = c.oid and a.atttypid = t.oid
ORDER BY a.attnum
这里的‘reg_user’是你要查询的表结构的数据表名称。