Re: Regarding varchar max length in postgres

From: Durgamahesh Manne <maheshpostgres9(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org, andreas(at)a-kretschmer(dot)de
Subject: Re: Regarding varchar max length in postgres
Date: 2018-10-15 09:18:32
Message-ID: CAJCZkoJN-vAZLOU1XHxVjCfh1UYtJvup958wRph+upxP9wkj3w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Oct 15, 2018 at 2:42 PM Durgamahesh Manne <maheshpostgres9(at)gmail(dot)com>
wrote:

>
>
> On Mon, Oct 15, 2018 at 2:35 PM Durgamahesh Manne <
> maheshpostgres9(at)gmail(dot)com> wrote:
>
>>
>>
>> On Mon, Oct 15, 2018 at 2:32 PM Durgamahesh Manne <
>> maheshpostgres9(at)gmail(dot)com> wrote:
>>
>>>
>>>
>>> On Fri, Oct 5, 2018 at 8:55 PM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
>>> wrote:
>>>
>>>> On 10/5/18 8:18 AM, Durgamahesh Manne wrote:
>>>> > Hi
>>>> >
>>>> > please let me know the max length of varchar & text in postgres
>>>>
>>>> https://www.postgresql.org/docs/10/static/datatype-character.html
>>>> >
>>>> >
>>>> >
>>>> > Regards
>>>> >
>>>> > Durgamahesh Manne
>>>>
>>>>
>>>> --
>>>> Adrian Klaver
>>>> adrian(dot)klaver(at)aklaver(dot)com
>>>
>>>
>>> Hi
>>>
>>> Thank you for this information
>>>
>>
> ((((as per the postgresql documentation
>
> If character varying is used without length specifier, the type accepts
> strings of any size
>
> but varchar does not accept more than this ))))
>
>>
>>> as per the postgresql documentation please ignore incomplete above
>>> message i mailed to respected community members
>>>
>>> If character varying is used without length specifier, the type
>>> accepts strings of any size
>>>
>>> but varchar does not accept more than this 10485760 value
>>>
>>
>> create table test(id serial primary key, str varchar(10485761));
>>
>> ERROR: length for type varchar cannot exceed 10485760
>>
>

as thomas said that

Further down on that page the overall limit is documented:

In any case, the longest possible character string that can be stored
is about 1 GB

So the part that you quoted implicitly means "accepts strings of any size
- up to the maximum of 1GB"
Maybe it makes sense to make that clearer at that point.

was there any specific reason that you have given max length for varchar is
limited to 10485760 value?

why you have not given max length for varchar is unlimited like text
datatype ?

character varying(*n*), varchar(*n*)variable-length with limit
character(*n*), char(*n*)fixed-length, blank padded
textvariable unlimited length

Regards

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Arthur Zakirov 2018-10-15 09:27:59 Re: Enabling autovacuum per table
Previous Message Raghavendra Rao J S V 2018-10-15 09:14:41 Re: Is there any impact if "#wal_keep_segments = 0 " and "checkpoint_segments = 128" postgresql.conf file.