MySQL numberic types----MySQL Numeric type-Introduction

Source: Internet
Author: User

Most of the programming languages have data types one says, although MySQL's SQL statements are different from standard SQL, the macro view is similar; let's talk about the numeric types in the MySQL database

one, in MySQL there are those types that can represent values :

1, bit[(m)] if M is not specified, in this case the M default is 1, that is, it can only save a bit, one is either zero, or one; M can take it in [1,64]

Mysql> Create TableT (xbit); Query OK,0Rows Affected (0.00sec) MySQL> Insert  intoT (x)Values(b'0'); Query OK,1Row affected (0.00sec) MySQL> Insert  intoT (x)Values(b'1'); Query OK,1Row affected (0.00sec) MySQL> SelectBin (x) fromT;+--------+|Bin (x)|+--------+| 0      || 1      |+--------+2Rowsinch Set(0.00sec)--since m default is 1, inserting B ' 11 ' is out of rangeMysql> Insert  intoT (x)Values(b' One'); ERROR1406(22001): Data tooLong  for column 'x'At row1

2, tinyint[(m)] [unsigned] [zerofill] very small integer, it occupies only one byte of storage space, the value range in [-128,127]

3, Bool,boolean It is the alias of tinyint (1), 0 means false not 0 means true

4, smallint[(m)] [unsigned] [zerofill] small integer, it only occupies two bytes of storage space

5, mediumint[(m)] [unsigned] [zerofill] It accounts for only three bytes of storage space

6, int[(m)] [unsigned] [zerofill] integer four bytes of storage space

7, bigint[(m)] [unsigned] [zerofill] Large integer Eight bytes of storage space

8, serial

----

MySQL numberic types----MySQL Numeric type-Introduction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.