|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
Does anyone know where in the system tables I can find the length of a particular column? I've had a look in the pg_attribute table, but it doesn't appear to show me the max length of my VarChar fields - the length appears as -1 (variable). Also, in which table is an attribute linked to a table? My hunch is that a lot of system table data is hidden from view but if anyone knows how I might get as the things I've mentioned, I'd be very grateful. Thanks in advance, NICK |
|
#2
|
|||
|
|||
|
For variable length fields, you need to check the atttypmod field. Postgres will add four more bytes (presumably to hold the actual size of the data?). For example, if a column is varchar(25), its value in atttypmod will be 29. By the way, in case your interested, the PHP function pg_fieldsize will only ever return '-1' for varchar fields, which I think is pretty weak. Fortunately it's a simple fix, just patch <php_4.1_source>/ext/pgsql/pgsql.c with this:
Code:
1018a1019,1021 > if ( return_value->value.lval == -1 ) > return_value->value.lval = PQfmod( pgsql_result, Z_LVAL_PP(field) ); > Sorry, just noticed the other part of your post: check out the online manual at http://www.postgresql.org/idocs/index.php?catalogs.html (I think there's even a mirror in Britain.) Last edited by billyo : December 24th, 2001 at 05:30 AM. |
![]() |
| Viewing: Dev Shed Forums > Databases > PostgreSQL Help > Column Length |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|