Re: Field length ?? - Mailing list pgsql-sql

From Louise Catherine
Subject Re: Field length ??
Date
Msg-id 20060420060838.46274.qmail@web33403.mail.mud.yahoo.com
Whole thread Raw
In response to Field length ??  (Louise Catherine <r1c4n@yahoo.com>)
Responses Re: Field length ??
List pgsql-sql
Hi ,<br /><br />With this table :<br />create table test(<br />satu char(10),<br />dua char(5)<br />);<br /><br />To
getthe field length, I use this query:<br /><br />select atttypmod from pg_attribute where <br />attname='satu' and <br
/>attrelid=(selectoid from pg_class where relname='test');<br />---> result 1 : 14<br /><br />select atttypmod from
pg_attributewhere <br />attname='dua' and <br />attrelid=(select oid from pg_class where relname='test');<br />--->
result2 : 9<br /><br /><br />Could anyone explain, why the field length must be add by 4 :<br />result 1 : 10 + 4
=14<br/>result 2 : 5 + 4 = 9<br /><br />Could I use this query ? Is it valid?<br />select atttypmod-4 from pg_attribute
where<br /> attname='satu' and <br /> attrelid=(select oid from pg_class where relname='test');<br /><br />Thank's,<br
/>Rina<br/><p><hr size="1" />How low will we go? Check out Yahoo! Messenger’s low <a
href="http://us.rd.yahoo.com/mail_us/taglines/postman8/*http://us.rd.yahoo.com/evt=39663/*http://voice.yahoo.com">
PC-to-Phonecall rates.</a> 

pgsql-sql by date:

Previous
From: Josh Berkus
Date:
Subject: Re: Programatically Backup Database Using Visual Basic
Next
From: Mariya Yuniarti
Date:
Subject: ask syntax sql to get length of field