Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What are MySql data types?
What are MySql data types?
Mysql supports multiple data types: numeric data type, date/time type and string type. ?

1. Integer data type and its value range:

type

explain

Storage Requirements (Value Range)

Tinyint is a small integer of 1 byte ([0~255], [-128 ~127]); 255=2^8- 1; 127=2^7- 1

Smallint integer 2 bytes (0~65535,-32768 ~ 32767); 65535=2^ 16- 1

3 bytes in (0 ~16777215); 167772 15=2^24- 1

Int(integer) ordinary 4 bytes (0 ~ 4294967295); 4294967295=2^32- 1

Bigint is an integer of 8 bytes (0 ~1844674073709551615); 1844674407370955 16 15=2^64- 1

Floating point number &; Fixed number of points:

Type name

explain

Storage requirements

Floating point single precision floating point number 4 bytes

Double double-precision floating-point number 8 bytes

Decimal compression "strict" fixed-point M+2 bytes

Note: Fixed points are stored in the form of strings, and it is better to use decimals when high precision is required; Try to avoid subtraction and comparison of floating-point numbers. ?

2. Time/date type:?

Year range:1901~ 2155; ?

Time format:' hh: mm: ss' (if writing is omitted and there is no colon, it defaults to the second digit of the rightmost digit, then the minute and finally the time); ?

Current time to insert the system: insert table name values (current_date ()), (now());); ?

Date type: "yyyy-mm-DD"; ?

Datetime (date+time):' yyyy-mm-DD hh: mm: SS' or' yyyymmdd hhmmss', with the range of'1000-01kloc-0/00: 00' ~' nine thousand nine hundred and ninety-nine. ?

The timestamp format is the same as that of datetime, except that it needs 4 bytes for storage (datetime needs 8 bytes) and UTC is used for storage (that is, the timestamp will change with the set time zone, but datetime will never change); Time stamp range: 1970-2037. ?

3. String type:?

Text type: tinyText, text, mediumtext, longtext.

type

range

tinytext 255=2^8- 1

SMS 65535 = 216-1

16777215 = 2 24-0/media

4294967295 = 4GB = 2 32-1long text

The storage requirement of char is a fixed length specified when it is defined; The storage requirements of varchar depend on the length of the actual value. ?

Set type format: set ('value 1',' value 2 '...)- can have 0 or more values. For set, if the inserted values are duplicate, only one will be combined. If the inserted values are out of order, the arrangement will be automatically inserted in order. If an abnormal value is inserted, it will be ignored. ?

Binary type:?

Bit(m)- saves the bit field value (bit field type), where m represents the number of digits of the value; ?

For example, select BIN(b+0) from the table name; -b is the column name; B+0 means to convert the binary result into the corresponding digital value, and the bin () function converts the digital value into binary. ?

Blog-a large binary object used to store a variable amount of data.

data type

Storage range (bytes)

Tinyblog is 255 = 2 8-1byte at most.

Bolg is at most 65535 = 2 16- 1 byte.

Mediumblog is at most1677 7215 = 2 24-1byte.

Longblog is at most 4294967295 = 4GB = 2 32- 1 byte.