sparkle sparkle - 2 years ago 100
SQL Question

Is better use an empty value as a '' or as NULL?

Database schema

I have this fields:

  • title (string)

  • subtitle

  • description (string)

Is better set the default value as an empty string '' or a NULL?

For better reading/writing and size-storage performance

Answer Source

The usual contract is:

  • NULL means "no information available".
  • '' means "there is information available. It's just empty."

Beyond this point there is much philosophical discussion since the invention of NULL in any language, not just SQL.

The only technical point here is: In PostgreSQL NULL can be stored more efficiently than a string of length zero. If that really matters in your case ... we cannot know.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download