mysql 中的tinyint 資料類型,mysqltinyint

來源:互聯網
上載者:User

mysql 中的tinyint 資料類型,mysqltinyint

mysql資料庫中以的類型是以 “ 資料類型(m) ” 來定義的 :


其中 數字m在不同的資料類型中表示含義是不同的。 


整型數系統已經限制了取值範圍,比如tinyint佔一個位元組(8bit)、int佔4個位元組。


所以整型數後面的m不是表示的資料長度,而是表示資料在顯示時顯示的最小長度(長度為字元數)。


tinyint(1) 這裡的1表示的是最小顯示寬度是1個字元。


tinyint(2) 這裡的2表示的是最小顯示寬度是2字元,但這裡光設定m是沒有意義的,你還需要指定當資料少於長度m時用什麼來填充,比如zerofill(表示有0填充)。


設定tinyint(2) zerofill 你插入1時他會顯示01。


設定tinyint(4) zerofill 你插入1時他會顯示0001。



Mysql 資料類型tinyint

這個應該是在代碼裡面控制的吧,直接在資料庫裡面查詢的話顯示不了吧。用代碼對查詢的結果處理一下就可以了。
 
MySQL資料類型的問題?

0 到 255
站位是1位元組
 

相關文章

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.