PostgreSQL data type text vs varchar without length

datatypespostgresql

In PostgreSQL you can create a column with data type character varying (without length precision) or text like this:

ALTER TABLE test ADD COLUMN c1 varchar;
ALTER TABLE test ADD COLUMN c2 text;

Is there a difference between these two data types?

The documentation is not clear about it. They say :

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

[…]

In addition, PostgreSQL provides
the text type, which stores strings of any length.

It seems that these two datatypes are equivalent but it is not explicit… More info about this?

Thank you,
Nico

Best Answer

There is no difference between the two data types. They use the exact same storage and the same operators.