postgresql数据库中,查询一个字段允许的最大长度的SQL语句怎么写?_百...
发布网友
发布时间:2022-04-23 00:45
我来回答
共1个回答
热心网友
时间:2022-04-10 07:49
对于character类型和character
varying类型的字段,也可以用一下语句查询。
SELECT
attname
as
"name",
typname
as
"type",
atttypmod
-
4
as
"size"
FROM
pg_class
AS
a
LEFT
OUTER
JOIN
pg_attribute
AS
b
ON
(b.attrelid
=
a.oid)
LEFT
OUTER
JOIN
pg_type
AS
c
ON
(b.atttypid
=
c.oid)
where
a.relname
=
'<tablename>'
and
attname='<fieldname>'
and
b.attstattarget
=
-1
order
by
attnum;
希望对你有所帮助。