16

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

1

1 Answer 1

12

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.