String storage size in sqlite

后端 未结 2 510
Happy的楠姐
Happy的楠姐 2020-12-29 04:12

After using lots of SQL Server and SQL Server Compact, I have recently started to use Sqlite. I\'m currently creating tables in Sqlite

2条回答
  •  旧时难觅i
    2020-12-29 04:48

    SQLite does let you write VARCHAR(255) or NVARCHAR(255), but the only relevant part of that is CHAR (which gives the column "text affinity"). The number in parentheses is allowed for compatibility with standard SQL, but is ignored.

    In SQLite, there's little need for length constraints on strings, because (1) it doesn't affect the amount of space the string takes up on disk and (2) there's no arbitrary limit (except for SQLITE_MAX_LENGTH) on the length of strings that can be used in an INDEX.

    If you have an actual need to place a limit on the number of characters in a column, just add a constraint like CHECK(LENGTH(TheColumn) <= 255).

提交回复
热议问题