Java,Oracle,MySQL資料設計資料類型參考

來源:互聯網
上載者:User
Java類 MySQL Oracle 位元組 範圍
Character char(1) char(1) 2 0~65535
String varchar(255) varchar2(255)    
String-clob longtext clob    
Date-date date date    
Date-time time date    
Date-timestamp datetime date    
Boolen tinyint(1) number(1) 1 true|false
Byte tinyint(4) number(3) 1 -128~127
Short smallint(6) number(5) 2 -32768~32767
Integer int(11) number(10) 4 -2147483648~2147483647
Long bigint(20) number(19) 8 -9223372036854775808 ~ 9223372036854775807
Float float float 4 -3.4E38~3.4E38 
Double double float 8 -1.7E308~1.7E308 
BigDecimal decimal(19,2) number(19,2)    
byte[]-blob longblob clob    

Float, Double盡量用BigDecimal替代,避免引起精度問題

Boolean在資料庫中有很多種表示方式,如0|1,  Y|N, YES|NO, 甚至用是|否表示 ,所以可以用number(1), char(1)甚至varchar2表示

為什麼MySQL和Oracle相差1,看了下面了你應該知道:

類型

位元組

最小值

最大值

 

 

(帶符號的/無符號的)

(帶符號的/無符號的)

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

9223372036854775807

 

 

0

18446744073709551615

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.