DB schema design - char, varchar, nchar, nvarchar and text
Database supplies mutilple field types to manage text data.
If the length of the data in a field is relatively fixed, you should use char.
If the length of the data varies, you should use varchar.
If the data is unicode (16 bits characters), you should nchar or nvarchar.
In old version, varchar and nvarchar can only hold chars no more than 8000 (?). In sql 2005 and future version, text, and ntext going to be replaced by varchar. (Image is replaced by varbinary(max)). Varchar(max) can hold 2(31) - 1 bytes or 2GB - 1 chars.
If the length of the data in a field is relatively fixed, you should use char.
If the length of the data varies, you should use varchar.
If the data is unicode (16 bits characters), you should nchar or nvarchar.
In old version, varchar and nvarchar can only hold chars no more than 8000 (?). In sql 2005 and future version, text, and ntext going to be replaced by varchar. (Image is replaced by varbinary(max)). Varchar(max) can hold 2(31) - 1 bytes or 2GB - 1 chars.

0 Comments:
Post a Comment
<< Home