Space used by nulls in database

前端 未结 6 1575
深忆病人
深忆病人 2020-12-03 13:32

If a column is null, does that affect the space used by the column? Is the space used fixed by the column definition? Does this vary from database to database. (I am mainly

6条回答
  •  青春惊慌失措
    2020-12-03 14:20

    In Oracle, it depends on type of the column and its position in the row.

    If the NULL columns are last in the row, then they don't take any space at all. Oracle prepends the total row size to each row, everything that doesn't fit is considered NULL.

    If there is some non-NULL data after a NULL column, then the NULL is stored as a single byte of 0xFF (that is, NULL type).

    Empty VARCHAR2 is equivalent to NULL. If you test the type of a literal NULL returned from SELECT list, it will give you a VARCHAR2(0).

提交回复
热议问题