Data Type Length (understood) database

1. When creating a database of int (10), varchar (255) behind the numbers in parentheses What does it mean?

Width number in parentheses is called data and different types of singular data processing are not the same width:

1, the width of the range of data types and an integer type, here is no relationship, but the width of the display indicates the maximum possible number of digits Mysql display, when the number of bits will be filled by a space width less than the specified value; if inserting a value greater than the width of the display, so long as the value does not exceed the range of the type, values ​​can still be inserted, and can be displayed.

Such as the above udi, the width of the display is 4, but I insert 100001 to the uid, is also possible, and will save the show is 100001

If you do not set a width, the system will add the default width tinyint (4), smallint (6), mediumint (9), int (11), bigint (20), which is the default width of the range of the type with a length related.

2, strings, strings were using the width of it really. Whether or char varchar, defines the maximum width of the length of the string

Such as password varchar (20) above, if you enter a 21-character password, then save and display only the first 20 characters, you will lose a character information, char empathy. Since varchar is a variable-length storage, so we generally regard the actual development of the width to the longest varchar 255, anyway, you do not run out of it will not be a waste of space.

3, floating point data types, and the width of the date data is not required, generally not provided, the default is 0

2.char and the difference between varchar

char: fixed-length, inadequate fill the seats

varchar: variable length

3. how the calculated size
4 bytes 32
2.31-1

int type unsigned band range with about:
Signed: (--2147483 648,2 147,483,647)
without sign: (0,4 294,967,295)    

How many characters can exist 3.varchar

How much a character length coding related accounts:

UTF-8: a = 3 bytes Character

GBK: a = 2 bytes Character

Guess you like

Origin www.cnblogs.com/coderMap/p/11294369.html