What type of text data format suitable for deposit into the database?

What type of text data format suitable for deposit into the database



Use database stores text data in the database will be following the patterns can be set to
char, varchar, nchar, nvarchar
then in the end what kind of patterns to use more appropriate, what is the difference between these patterns it ??

Meanings and Differences

From the point of view of these words, we are all char, and var n differences in these two words, then the first to briefly explain the meaning of these two words represent:

var: → indefinite length how long forever

n: Unicode → Whether English, numbers, Chinese, Japanese, ... every word accounted 2Byte.

Explain:

char and nchar statement is fixed length, so if the statement char (5), but just put a word, it will make up the other four blank, blank fill will fill up his features, and nchar (5) is It will be filled with five words, but each word in English regardless of the number will be used to store two Bytes

varchar and nvarchar is a variable length, so if statement varchar (5), but just put a word, it will put a a, do not fill the blank . If the statement nvarhcar (5) and that was just put a word, but will be used to store 2Bytes. If you put [ in the text], in varchar it will take up 2 seats, but nvarchar will occupy 1 seats.

For example of view

Suppose there are four fields, respectively, into the [a1] in such strings, compare these differences are as follows:

type of data content Accounting digit Byte count
char(10) a1 blank +6 10 10
varchar(10) a1, 4 1+1+2=4
nchar(10) a1 blank +7 10 20
nvarchar(10) a1, 3 2*3=6

Again comparing a char (10) and nchar (10)

1

2

3

4

5

6

7

8

9

10

char(10)

a 1

in

           
Second place

1

2

3

4

5

6

7

8

9

10

nchar(10)

a   1  

in

                           

Therefore, in the planning, as long as the data stored there may be Chinese , a small meow will increase the n- . And unless the data can be determined fixed several invariant, or data length is not certain it will add the statement var .

This article is posted, the original: [extreme cohesion between topcat Shan dance]



Original: Large columns  of text patterns in what format the data for deposit into the database?


Guess you like

Origin www.cnblogs.com/petewell/p/11516512.html