Java entity properties correspond to MySQL and SQL Server and Oracle data types

Source: Internet
Author: User
Tags comparison table local time java se

1:java data type and MySQL data type comparison table

Type name Display length Database type Java type JDBC Type index (int)
VARCHAR L+n VARCHAR Java.lang.String 12
CHAR N CHAR Java.lang.String 1
Blob L+n Blob Java.lang.byte[] -4
TEXT 65535 VARCHAR Java.lang.String -1
INTEGER 4 INTEGER UNSIGNED Java.lang.Long 4
TINYINT 3 TINYINT UNSIGNED Java.lang.Integer -6
SMALLINT 5 SMALLINT UNSIGNED Java.lang.Integer 5
Mediumint 8 Mediumint UNSIGNED Java.lang.Integer 4
BIT 1 BIT Java.lang.Boolean -7
BIGINT 20 BIGINT UNSIGNED Java.math.BigInteger -5
FLOAT 4+8 FLOAT Java.lang.Float 7
DOUBLE 22 DOUBLE Java.lang.Double 8
DECIMAL 11 DECIMAL Java.math.BigDecimal 3
BOOLEAN 1 With tinyint
Id 11 PK (INTEGER UNSIGNED) Java.lang.Long 4
DATE 10 DATE Java.sql.Date 91
Time 8 Time Java.sql.Time 92
Datetime 19 Datetime Java.sql.Timestamp 93
TIMESTAMP 19 TIMESTAMP Java.sql.Timestamp 93
Year 4 Year Java.sql.Date 91


* For Bolb, generally used for image database storage, the principle is to make the picture into binary, and then do a storage method, in Java corresponding to the byte[] array.

For the Boolen type, in the MySQL database, the individual think that using the int type is better, the bit operation is not very convenient, especially in the project with Web page development, represents 0/1, corresponding to the Java type of integer is better.

2:sqlserver database corresponds to data type in Java

SQL Server Type JDBC Type (java.sql.Types) Java Language Types

bigint

BIGINT

Long

Timestamp

Binary

BINARY

Byte[]

Bit

BIT

Boolean

Char

CHAR

String

Decimal

Money

SmallMoney

DECIMAL

Java.math.BigDecimal

Float

DOUBLE

Double

Int

INTEGER

Int

Image

varbinary (max)

LongVarBinary

Byte[]

varchar (max)

Text

LongVarChar

String

NChar

CHAR

NCHAR (Java SE 6.0)

String

nvarchar

VARCHAR

NVARCHAR (Java SE 6.0)

String

nvarchar (max)

ntext

LongVarChar

Longnvarchar (Java SE 6.0)

String

Numeric

NUMERIC

Java.math.BigDecimal

Real

REAL

Float

smallint

SMALLINT

Short

Datetime

smalldatetime

TIMESTAMP

Java.sql.Timestamp

varbinary

Udt

VARBINARY

Byte[]

varchar

VARCHAR

String

tinyint

TINYINT

Short

uniqueidentifier

CHAR

String

Xml

LongVarChar

SQLXML (Java SE 6.0)

String

SQLXML

Time

Time (1)

Java.sql.Time (1)

Date

DATE

Java.sql.Date

DateTime2

TIMESTAMP

Java.sql.Timestamp

DateTimeOffset (2)

Microsoft.sql.Types.DATETIMEOFFSET

Microsoft.sql.DateTimeOffset

3: SQL Server and Oracle data type correspondence

SQL Server 2k conversion to Oracle 10g

Column Name SQL Server Data type SQL Server length Oracle data types
Column1 bigint 8 Number (19)
Column2 Binary 50 RAW (50)
Column3 Bit 1 Number (2)
Column4 Char 10 CHAR (10)
Column5 Datetime 8 DATE
Column6 Decimal 9 Number (18)
Column7 Float 8 Binary_double
Column8 Image 16 Blob
Column9 Int 4 Number (10)
Column10 Money 8 Number (19,4)
Column11 NChar 10 NCHAR (10)
Column12 ntext 16 NCLOB
Column13 Numeric 9 Number (18)
Column14 nvarchar 50 NVARCHAR2 (50)
Column15 Real 4 Binary_float
Column16 smalldatetime 4 DATE
Column17 smallint 2 Number (5)
Column18 SmallMoney 4 Number (10,4)
Column19 sql_variant Blob
Column20 Text 16 Clob
Column21 Timestamp 8 RAW (8)
Column22 tinyint 1 Number (3)
Column23 uniqueidentifier 16 Blob
Column24 varbinary 50 RAW (50)
Column25 varchar 50 VARCHAR2 (50)

Oracle 10g translates to SQL Server 2k

Oracle Column Name Oracle data types SQL Server Column Name SQL Server Data type SQL Server Data length
COLUMN1 Binary_double COLUMN1 Float 8
COLUMN2 Binary_float COLUMN2 Real 4
COLUMN3 Blob COLUMN3 Image 16
COLUMN4 Clob COLUMN4 ntext 16
COLUMN5 CHAR (10) COLUMN5 NChar 10
COLUMN6 DATE COLUMN6 Datetime 8
COLUMN12 Number COLUMN12 Numeric 13
COLUMN13 NVARCHAR2 (10) COLUMN13 nvarchar 10
COLUMN14 RAW (10) COLUMN14 varbinary 10
COLUMN15 TIMESP (6) COLUMN15 Datetime 8
COLUMN16 TIMESP (6) with LOCAL time ZONE COLUMN16 Datetime 8
COLUMN17 TIMESP (6) with time ZONE COLUMN17 Datetime 8
COLUMN18 VARCHAR2 (10) COLUMN18 nvarchar 10
COLUMN7 INTERVAL Day (2) to SECOND (6) COLUMN7 nvarchar 30
COLUMN8 INTERVAL year (2) to MONTH COLUMN8 nvarchar 14
COLUMN9 LONG COLUMN9 ntext 16
COLUMN10 LONG RAW COLUMN10 Image 16
COLUMN11 NCLOB COLUMN11 ntext 16

The above are excerpts from a number of blog finishing.

Java entity properties correspond to MySQL and SQL Server and Oracle data types

Related Article

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.