Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is VARCHAR like totally 1990s? [closed]

  1. VARCHAR does not store Unicode characters.
  2. NVARCHAR does store Unicode characters.
  3. Today's applications should always be Unicode compatible.
  4. NVARCHAR takes twice the amount of space to store it.
  5. Point 4 doesn't matter because storage space is extremely inexpensive.

Ergo: When designing SQL Server databases today, one should always use NVARCHAR.

Is this sound reasoning? Does anyone disagree with any of the premises? Are there any reasons to choose VARCHAR over NVARCHAR today?

like image 836
Edward Tanguay Avatar asked Nov 23 '08 05:11

Edward Tanguay


People also ask

What is meant by VARCHAR 20?

The data type of varchar is Variable-length with non-Unicode character data. The storage size is the actual length of data entered + 2 bytes. • For varchar (20): The max storage size is: 20*1 byte +2 bytes=22 bytes; •

Why you shouldn't use VARCHAR Max?

DO NOT use VARCHAR(MAX) just because it can be. Use it only if the data to be stored can be more than 8,000 bytes.

Does VARCHAR use all space?

Varchar(max) stores a maximum of 2,147,483,647 characters. But, varchar(50) keeps the 50 character space even if you don't store 50 characters. but varchar(max) is flexible to any size. size doesn't matter.

What is data type VARCHAR?

The VARCHAR data type stores character strings of varying length that contain single-byte and (if the locale supports them) multibyte characters, where m is the maximum size (in bytes) of the column and r is the minimum number of bytes reserved for that column.


1 Answers

You match the datatype with the data that will be stored in the column. By a similar argument you could say why not store all data in NVARCHAR columns, because numbers and dates can be represented as strings of digits.

If the best match for the data that will be stored in the column is VARCHAR, then use it.

like image 196
dkretz Avatar answered Sep 22 '22 10:09

dkretz