Database design : preferred field length for file paths

前端 未结 7 944
南笙
南笙 2021-01-04 02:49

I have to store file paths in a DB field (/tmp/aaa/bbb, C:\\temp\\xxx\\yyy, etc.). I can\'t really tell how long they could be.

Given this

7条回答
  •  花落未央
    2021-01-04 03:25

    You can use VARCHAR(MAX) or NVARCHAR(MAX).

    These are variable length fields meaning they are designed to store values of different length. There is no extra overhead for longer values over shorter values.

    Defining MAX means the field can be up to 2GB.

    From MSDN (varchar), nvarchar has similar documentation:

    Use varchar when the sizes of the column data entries vary considerably.

    Use varchar(max) when the sizes of the column data entries vary considerably, and the size might exceed 8,000 bytes.

提交回复
热议问题