Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 743
Samir Avatar asked Mar 29 '16 09:03

Samir


People also ask

What is maximum length of character varying Postgres?

The maximum limit of size character using character varying data type in PostgreSQL is 10485760. The below example shows that the size of the character using character varying data type in PostgreSQL is 10485760.

What is character varying data type in PostgreSQL?

PostgreSQL supports a character data type called VARCHAR. This data type is used to store characters of limited length. It is represented as varchar(n) in PostgreSQL, where n represents the limit of the length of the characters. If n is not specified it defaults to varchar which has unlimited length.

What is VARCHAR Max in PostgreSQL?

What is PostgreSQL Varchar datatype? In PostgreSQL, the Varchar data type is used to keep the character of infinite length. And it can hold a string with a maximum length of 65,535 bytes.

Is character varying same as VARCHAR?

VARCHAR is an alias for CHARACTER VARYING , so no difference, see documentation :) The notations varchar(n) and char(n) are aliases for character varying(n) and character(n) , respectively. character without length specifier is equivalent to character(1) .


2 Answers

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

like image 143
a_horse_with_no_name Avatar answered Oct 11 '22 14:10

a_horse_with_no_name


You should use TEXT data type for this use-case IMO.

enter image description here https://www.postgresql.org/docs/9.1/datatype-character.html

like image 26
mecampbellsoup Avatar answered Oct 11 '22 13:10

mecampbellsoup