MySQL中整各種int類型的範圍和儲存大小,mysqlint

來源:互聯網
上載者:User

MySQL中整各種int類型的範圍和儲存大小,mysqlint

    MySQL中中的整數類型int主要有如下幾種:


    tinyint 的範圍是-128~127;

    int的範圍是-2^31 (-2,147,483,648) 到 2^31 – 1 (2,147,483,647) 的整型資料(所有數字),儲存大小為4個位元組;

    bigint的範圍是 -2^63 (-9223372036854775808) 到 2^63-1 (9223372036854775807) 的整型資料(所有數字)。儲存大小為 8 個位元組;

    smallint unsigned的範圍是 –2^15(2^15表示2的15次冪) 到2^15 – 1,即 –32768 到 32767;

    smallint 的範圍是 0 到 2^16 – 1,即 0 到 65535,儲存的位元組是2個位元組。


    我們在設計的時候要注意儘可能使用較小資料類型。

相關文章

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.