4

I see different schemas using TEXT, CHAR, VARCHAR, CHARACTER VARYING, CHAR VARYING to store string data. Which should I use in CockroachDB?

benesch
  • 5,239
  • 1
  • 22
  • 36

1 Answers1

3

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

In CockroachDB, the following are aliases for STRING:

  • CHARACTER
  • CHAR
  • VARCHAR
  • TEXT

And the following are aliases for STRING(n):

  • CHARACTER(n)
  • CHARACTER VARYING(n)
  • CHAR(n)
  • CHAR VARYING(n)
  • VARCHAR(n)

CockroachDB will treat all of these types identically. The canonical name for the type in CockroachDB, however, is STRING, so if you're starting a new application from scratch, you'll reduce confusion by preferring STRING over the other aliases.

Community
  • 1
  • 1
benesch
  • 5,239
  • 1
  • 22
  • 36