Skip site navigation (1) Skip section navigation (2)

column length?

From: "Mark McArthey" <mcarthey(at)execpc(dot)com>
To: "PgSQL Novice" <pgsql-novice(at)postgresql(dot)org>
Subject: column length?
Date: 2001-10-23 19:25:31
Message-ID: CGEFKOCNLBFDGLJODOGIMEJECDAA.mcarthey@execpc.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi all,
I am wondering how the column length is determined.  The attached output is
for my test table.  Running '\d player' shows me that the columns are
varchar(20), but the attlen is listed as -1.  Where does the value '20' come
from?
Thanks!
Mark

> psql -E

=# \d player
********* QUERY *********
SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules
FROM pg_class WHERE relname='player'
*************************

********* QUERY *********
SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull,
a.atthasdef, a
.attnum
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = 'player'
AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid
ORDER BY a.attnum
*************************

Table "player"
Attribute |    Type     | Modifier
-----------+-------------+----------
name      | varchar(20) |
password  | varchar(20) |


=# \i query1.sql
relhasindex | relkind | relchecks | reltriggers | relhasrules
-------------+---------+-----------+-------------+-------------
f           | r       |         0 |           0 | f
(1 row)

markm=# \i query2.sql
attname  | typname | attlen | atttypmod | attnotnull | atthasdef | attnum
----------+---------+--------+-----------+------------+-----------+--------
name     | varchar |     -1 |        24 | f          | f         |      1
password | varchar |     -1 |        24 | f          | f         |      2
(2 rows)



Responses

pgsql-novice by date

Next:From: Josh BerkusDate: 2001-10-23 22:51:20
Subject: Re: Performance question (PostgreSQL 7.1.3)
Previous:From: Travis HoytDate: 2001-10-23 19:11:51
Subject: [Fwd: views, with check option]

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group