[Gdal-dev] PostGIS varchar fields

William Kyngesburye woklist at kyngchaos.com
Wed Jan 11 23:20:25 EST 2006


In SQL databases, a varchar field has a maximum length.  Just like a  
fixed char field, it can't store a string longer than that.  The  
variable part is just how it stores the string.  You should get that  
max length when you query the field definitions.


On Jan 11, 2006, at 9:19 PM, Frank Warmerdam wrote:

> On 1/11/06, William Kyngesburye <woklist at kyngchaos.com> wrote:
>> I did not use the precision option.  But they are varchars in the
>> PostGIS DB - I verified that by browsing the DB with phppgadmin.  I
>> thinks that's because I originally created it by importing just the
>> geometry with no attributes (I was experimenting),then cleared it,
>> then added the attribute fields with SQL commands.  Then I appended
>> to the DB with OGR with mif/mid's with full attributes.  So, the
>> PostGIS DB does have varchars.  I'd have to scan the DB (large), or
>> test on a separate one, to see if any name strings were cut off at 80
>> chars (if the fields are already varchar, does -append still cut off
>> at 80 chars if the default precision=true is used?).
>>
>> So, back to the question, is OGR supposed to recognize varchar field
>> lengths in postgis?
>
> William,
>
> I think I am confused.  If a field is declared "VARCHAR"
> doesn't it have a variable length?  That is certainly
> the assumption of the OGR code that builds the OGR
> field definitions from a table, which means that when
> going to shapefile I have to pick an arbitrary field length
> for the .dbf file.
>

-----
William Kyngesburye <kyngchaos at kyngchaos.com>
http://www.kyngchaos.com/

"I ache, therefore I am.  Or in my case - I am, therefore I ache."

- Marvin




More information about the Gdal-dev mailing list