What's the difference between TEXT, CHAR and VARCHAR in CockroachDB?

I see a variety of schemes, using TEXT

, CHAR

, VARCHAR

, CHARACTER VARYING

, CHAR VARYING

to store string data. What should I use in CockroachDB?

+3


source to share


1 answer


All types mentioned are equivalent; see the CockroachDB STRING documentation for an exhaustive list.

CockroachDB has the following aliases for STRING

:

  • CHARACTER

  • CHAR

  • VARCHAR

  • TEXT

And the following aliases are for STRING(n)

:

  • CHARACTER(n)

  • CHARACTER VARYING(n)

  • CHAR(n)

  • CHAR VARYING(n)

  • VARCHAR(n)



CockroachDB will handle all of these types in the same way. The canonical name for a type in CockroachDB is, however, STRING

so if you start a new application from scratch, you will reduce confusion by preferring STRING

over other aliases.

+2


source







All Articles