what’s the difference between a null value and an empty string in a table

tags: learning database diff-between

content

in a table, when we store a record, string for example, what’s the difference between null and ''

  • database uses a flag to track which column is null
    • the flag is just 1 bit in a null bitmap
    • the flag is basically metadata for the column
  • an empty string is still a string
    • it’s a real string with length of 0
    • the string still takes up space
  • a null still takes space (metadata), but it takes very little space, it’s way more space efficient than empty string

up

down

reference