Mysql, Oracle, and Java Data types _mysql

Source: Internet
Author: User
Mysql, Oracle, and Java Data types
Mysql Oracle Java

BIGINT

NUMBER (19,0)


Java. lang. Long

BIT

RAW


Byte []

BLOB

BLOB RAW


Byte []

CHAR

CHAR


Java. lang. String
DATE DATE Java. SQL. Date
DATETIME DATE Java. SQL. Timestamp
DECIMAL FLOAT (24)
Java. math. BigDecimal
DOUBLE FLOAT (24) Java. lang. Double
DOUBLE PRECISION FLOAT (24) Java. lang. Double
ENUM VARCHAR2
Java. lang. String
FLOAT FLOAT Java. lang. Float

INT

NUMBER (10, 0)


Java. lang. Integer

INTEGER

NUMBER (10, 0)

Java. lang. Integer

LONGBLOB BLOB RAW Byte []
LONGTEXT CLOB RAW Java. lang. String
MEDIUMBLOB BLOB RAW Byte []

MEDIUMINT

NUMBER (7,0)
Java. lang. Integer
MEDIUMTEXT CLOB RAW Java. lang. String
NUMERIC NUMBER
REAL FLOAT (24)

SET

VARCHAR2


Java. lang. String

SMALLINT

NUMBER (5, 0)


Java. lang. Integer

TEXT

VARCHAR2 CLOB
Java. lang. String
TIME DATE Java. SQL. Time
TIMESTAMP DATE Java. SQL. Timestamp
TINYBLOB RAW Byte []
TINYINT NUMBER (3, 0) Java. lang. Boolean
TINYTEXT VARCHAR2 Java. lang. String
VARCHAR VARCHAR2 CLOB Java. lang. String

YEAR

NUMBER

Java. SQL. Date (Date is set to, January 1, February 1)

// Relationship between the number of bytes

Java byte count
Data type size (binary digits) range default value byte (byte) 8-128-127 0 shot (short integer) 16-32768-32768 0int (integer) 32-2147483648-2147483648 0 long (long integer) 64-9233372036854477808-9233372036854477808 0 float (float type) 32-3.40292824e + 38-3.40292824e + 38 0.0 fdouble (double precision) 64-1.79769313486231570E + 308-1.79769313486231570E + 308 0.0 dchar (character type) 16'/u0000-u/ffff ''/u000000'
Boolean (boolean) 1 true/false
What are the basic JAVA data types in bytes? Byte1 byte short2 byte int4 byte long8 byte char2 byte (1 byte in C) can store a Chinese character float4 byte double8 byte booleanfalse/true (theoretically occupies 1 bit, 1/8 bytes, 1 byte for actual processing) 
                                   
JAVA adopts Unicode encoding. Each byte occupies 8 bits. Your computer system should be a 32-bit system, so each int is 4 bytes
One byte consists of eight binary digits.
Java has a total of eight basic data types (original data types): type storage requirements range (inclusive) default packaging class integer int 4 bytes (32-bit)-231 ~ 231-1 0 Integer number short 2 bytes (16 bits)-215 ~ 215-1 0 Short class long 8 bytes (64-bit)-263 ~ 263-1 0 Long byte 1 byte (8 bits)-27 ~ 27-1 0 Byte floating point float 4 bytes (32 bits)-3.4e + 38 ~ 3.4e + 38 0.0f Float type double 8 bytes (64-bit)-1.7e + 308 ~ 1.7e + 308 0 Double character char 2 byte (16 bits) u0000 ~ UFFFF (''~ '? ') '0' Character (0 ~ 216-1 (65535) boolean Boolean 1/8 bytes (1 bit) true, false FALSE boolean
In mobile development, due to the limitations of the memory of mobile devices, you must consider the number of bytes occupied by the data type. The following describes several basic data types in Java to deepen the memory. 

There are a total of eight basic data types in Java, including four integer types and two floating point types, one character type is used to represent the character units of Unicode encoding and one boolean type used to represent the true value. (One byte equals eight bits)

1. integer
Remarks on the value range of bits required for type storage
Int 4-byte 4*8
Short 2-byte 2*8-32768 ~ 32767
Long 8-byte 8*8
Byte 1 byte 1x8-128 ~ 127

2. Floating point type
Remarks on the value range of bits required for type storage
Float 4-byte 4*8 float type value has a suffix F (for example, 3.14F)
Double 8 byte 8*8 floating point value without suffix F (for example, 3.14) the default value is double type

3. char type
Remarks on the value range of bits required for type storage
Char 2 bytes 2*8

4. boolean type
Remarks on the value range of bits required for type storage
Boolean 1 byte 1*8 false, true


Supplement: Java has a computation bag that can represent any precision. it is usually called "big number ). Although it is called a big value, it is not a Java type, but a Java object.

If the precision of the basic integer and floating point cannot meet the requirements, you can use java. two useful classes in the math package: BigIntegerBigDecimal (the Android SDK also contains java. math package and these two classes) these two classes can process values that contain numbers of any length. The BigInteger class implements integer operations with any precision, while the BigDecimal class implements floating point operations with any precision. For specific usage, see Java API.

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.