Can we create a column of character varying(MAX) with PostgreSQL database

Samir picture Samir · Mar 29, 2016 · Viewed 25.3k times · Source

I am unable to set the max size of particular column in PostgreSQL with MAX keyword. Is there any keyword like MAX. If not how can we create the column with the maximum size?

Answer

a_horse_with_no_name picture a_horse_with_no_name · Mar 29, 2016

If you want to created an "unbounded" varchar column just use varchar without a length restriction.

From the manual:

If character varying is used without length specifier, the type accepts strings of any size

So you can use:

create table foo
( 
  unlimited  varchar
);

Another alternative is to use text:

create table foo
( 
  unlimited text
);

More details about character data types are in the manual:
http://www.postgresql.org/docs/current/static/datatype-character.html