Difference between different string types in SQL Server?

前端 未结 9 1458
情书的邮戳
情书的邮戳 2020-12-29 04:22

What is the difference between char, nchar, ntext, nvarchar, text and varchar in SQL?

I

9条回答
  •  被撕碎了的回忆
    2020-12-29 04:51

    N prefix indicates unicode support and takes up twice the bytes per character of non-unicode.

    Varchar is variable length. You use an extra 2 bytes per field to store the length.

    Char is fixed length. If you know how long your data will be, use char as you will save bytes!

    Text is mostly deprecated in my experience.

    Be wary of using Varchar(max) and NVarchar(max) as these fields cannot be indexed.

提交回复
热议问题