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

asked Jul 2, 2012 at 12:28
1

1 Answer 1

12

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

answered Jul 12, 2012 at 6:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.