Java class |
MySQL |
Oracle |
Bytes |
Range |
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 |
|
|
Use bigdecimal instead of float and double to avoid precision problems.
Boolean has many Representation Methods in the database, such as 0 | 1, Y | N, yes | no, or even Yes | no, so number (1) can be used ), char (1) or even varchar2
Why is the difference between MySQL and Oracle 1? after reading the following information, you should know:
Type |
Bytes |
Minimum value |
Maximum Value |
|
|
(Signed/unsigned) |
(Signed/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 |
9223372036854775807 |
|
|
0 |
18446744073709551615 |