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
If your using SQL Server, it's good to know that Microsoft is using nvarchar(260) fields to store file path and name in the system tables (like sys.database_files, or sys.sysaltfiles, or sys.master_files).
Column name Data type Description ------------- ------------- --------------------------- physical_name nvarchar(260) Operating-system file name.
Good practice could be to use the same format to store your path and file name.
You will, of course, need to enforce the size in your UI to be sure that it will not be truncated during INSERT or UPDATE.