2014-11-09

Just use 'TEXT' type in Postgres

Sometimes it is the little things that trip you up, especially when learning a new tool. Like which data type to choose when creating a new database in a SQL system. But not so simple.

Here are two posts that make a strong case for just using TEXT in Postgres while avoiding VARCHAR and CHAR. I agree. Wish I'd seen this long ago.

And for more info, experimentation, and discussion, see the post CHAR(X) VS. VARCHAR(X) VS. VARCHAR VS. TEXT by depesz.

The upshot is:
  • Use the TEXT type for all your textual needs.
  • If constraining the maximum, minimum, and content is important then define a CONSTRAINT. (No need to depend on the max length feature of varchar.)
As counter argument, see IN DEFENSE OF VARCHAR(X) by Leo Hsu and Regina Obe.

1 comment:

  1. Here is the posts that make a strong case for just using TEXT in Postgres while avoiding VARCHAR and CHAR. Download Free Crack Software Full Version

    ReplyDelete