mysql与java数据类型对应关系
1:Java数据类型与MySql数据类型对照表
类型名称显⽰长度数据库类型JAVA类型JDBC类型索引(int)
VARCHAR L+N VARCHAR java.lang.String12
CHAR N CHAR java.lang.String1
BLOB L+N BLOB java.lang.byte[]-4
TEXT65535VARCHAR java.lang.String-1
INTEGER4INTEGER UNSIGNED java.lang.Long4
TINYINT3TINYINT UNSIGNED java.lang.Integer-6
SMALLINT5SMALLINT UNSIGNED java.lang.Integer5
MEDIUMINT8MEDIUMINT UNSIGNED java.lang.Integer4
BIT1BIT java.lang.Boolean-7
BIGINT20BIGINT UNSIGNED java.math.BigInteger-5
FLOAT4+8FLOAT java.lang.Float7
DOUBLE22DOUBLE java.lang.Double8
DECIMAL11DECIMAL java.math.BigDecimal3
BOOLEAN1同TINYINT
ID11PK (INTEGER UNSIGNED)java.lang.Long4
DATE10DATE java.sql.Date91
TIME8TIME java.sql.Time92
DATETIME19DATETIME java.sql.Timestamp93
TIMESTAMP19TIMESTAMP java.sql.Timestamp93
91
YEAR4YEAR java.sql.Date
*对于bolb,⼀般⽤于对图⽚的数据库存储,原理是把图⽚打成⼆进制,然后进⾏的⼀种存储⽅式,在java中对应byte[]数组。
对于boolen类型,在mysql数据库中,个⼈认为⽤int类型代替较好,对bit操作不是很⽅便,尤其是在具有web页⾯开发的项⽬中,表⽰0/1,对应java类型的Integer较好。
2: sqlserver数据库对应java中的数据类型
SQL Server 类型JDBC 类型 (java.sql.Types)Java 语⾔类型
bigint BIGINT long
timestamp
BINARY byte[]
binary
bit BIT boolean
char CHAR Stringbigdecimal转换为integer
decimal
money DECIMAL java.math.BigDecimal
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
datetime2TIMESTAMP java.sql.Timestamp datetimeoffset (2)microsoft.sql.Types.DATETIMEOFFSET microsoft.sql.DateTimeOffset
3:sqlserver和Oracle数据类型对应关系
SqlServer 2k转换为 10g
列名SqlServer数据类型SqlServer长度Oracle数据类型
column1bigint8NUMBER(19)
column2binary50RAW(50)
column3bit1NUMBER(2)
column4char10CHAR(10)
column5datetime8DATE
column6decimal9NUMBER(18)
column7float8BINARY_DOUBLE
column8image16BLOB
column9int4NUMBER(10)
column10money8NUMBER(19,4)
column11nchar10NCHAR(10)
column12ntext16NCLOB
column13numeric9NUMBER(18)
column14nvarchar50NVARCHAR2(50)
column15real4BINARY_FLOAT
column16smalldatetime4DATE
column17smallint2NUMBER(5)
column18smallmoney4NUMBER(10,4)
column19sql_variant BLOB
column20text16CLOB
column21timestamp8RAW(8)
column22tinyint1NUMBER(3)
column23uniqueidentifier16BLOB
column24varbinary50RAW(50)
VARCHAR2(50)
column25varchar50
Oracle 10g 转换为SqlServer 2k
Oracle列名Oracle数据类型SqlServer列名SqlServer数据类型SqlServer数据长度COLUMN1BINARY_DOUBLE COLUMN1float8
COLUMN2BINARY_FLOAT COLUMN2real4
COLUMN3BLOB COLUMN3image16
COLUMN4CLOB COLUMN4ntext16
COLUMN5CHAR(10)COLUMN5nchar10
COLUMN6DATE COLUMN6datetime8
COLUMN12NUMBER COLUMN12numeric13
COLUMN13NVARCHAR2(10)COLUMN13nvarchar10
COLUMN14RAW(10)COLUMN14varbinary10
COLUMN15TIMESP(6)COLUMN15datetime8 COLUMN16TIMESP(6) WITH LOCAL TIME ZONE COLUMN16datetime8 COLUMN17TIMESP(6) WITH TIME ZONE COLUMN17datetime8 COLUMN18VARCHAR2(10)COLUMN18nvarchar10 COLUMN7INTERVAL DAY(2) TO SECOND(6)COLUMN7nvarchar30 COLUMN8INTERVAL YEAR(2) TO MONTH COLUMN8nvarchar14 COLUMN9LONG COLUMN9ntext16 COLUMN10LONG RAW COLUMN10image16 COLUMN11NCLOB COLUMN11ntext16

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。