当前位置:网站首页>MySQL digital type learning notes

MySQL digital type learning notes

2022-07-05 10:08:00 51CTO

Numeric type

Recently in to see 《MySQL Technology insider :SQL Programming 》 And made notes , So this blog is a blog of note type , Share it for your review , Can also help others

  • integer

type

Occupancy space

minimum value (SIGNED)

Maximum (SIGNED)

minimum value (UNSIGNED)

Maximum (UNSIGNED)

TINYINT

1

-128

127

0

255

SMALLINT

2

-32768

32767

0

65535

MEDIUMINT

3

-8388608

8388607

0

16777215

INT

4

-2147483648

2147483647

0

4294967295

BIGINT

8

-9223372036854775808

9223372036854775808

0

18446744073709551615

  • A type of
    A type of , Keywords are bit, The bit type is used to store the value of the bit field ,BIT(M),M Indicates the value of the number of bits allowed to be stored ,M For the range of 1 To 64, The space occupied is (M+7)/8 byte


Be careful : If the length of the assigned value is less than M position , Use it on the left of the value 0 fill


      
      
# Create a table
CREATE TABLE t(a BIT(4));
# Write data
INSERT INTO t SELECT b'1000';
# Inquire about , Display the string in the new version , You can't check it directly
SELECT * FROM t;
# Bit type , It can be used HEX function , The result is a number 8(16 Base number )
SELECT HEX(a) FROM t;
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • floating-point ( Imprecise type )
    MySQL Two floating point types are supported : Single precision FLOAT Type and double precision DOUBLE type
  • High precision type
    DECIMAL and NUMERIC yes MySQL Types with relatively high progress , Grammar is DECIMAL(M,N)、NUMERIC(M,N),M Representation precision , That is, the number of digits of the whole value ,, Two types of maximum digits M All for 65,N Indicates the scale , That is, the number of digits after the decimal point of the whole value
原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050933107001.html