本章枚举并说明SQL ISO规范中给定的数据类型,并列出JDBC规范及Oracle、SQLServer对应的数据类型。
大类 | ISO/ANSI | JDBC | Oracle | SQLServer | MySQL | PostgreSQL |
文本 | CHARACTER(n) | CHAR | CHAR | char | ||
CHARACTER VARYING(n) | VARCHAR | VARCHAR (VARCHAR2) | varchar | |||
CHARACTER LARGE OBJECT | CLOB | CLOB | text | |||
NATIONAL CHARACTER(n) | NCHAR | NCHAR | nchar | |||
NATIONAL CHARACTER VARYING(n) | NVARCHAR | NVARCHAR (NVARCHAR2) | nvarchar | |||
NATIONAL CHARACTER LARGE OBJECT | NCLOB | NCLOB | ntext | |||
字节 | BINARY(n) | BINARY | × | binary | ||
BINARY VARYING(n) | VARBINARY | × | varbinary | |||
BINARY LARGE OBJECT | BLOB | BLOB | image | |||
整形 | SMALLINT | SMALLINT | NUMBER(5) | smallint | ||
INTEGER | INTEGER | NUMBER(10) | int | |||
BIGINT | BIGINT | NUMBER(38) | bigint | |||
数值 | DECIMAL | DECIMAL | DECIMAL (NUMBER) | decimal | ||
NUMERIC | NUMERIC | NUMERIC (NUMBER) | numeric | |||
REAL | REAL | REAL | real | |||
FLOAT | FLOAT | FLOAT BINARY_FLOAT | float | |||
DOUBLE PRECISION | DOUBLE | DOUBLE BINARY_DOUBLE | ||||
DECFLOAT | × | × | × | |||
布尔 | BOOLEAN | BOOLEAN | × | bit | ||
日期 | DATE | DATE | DATE | date | ||
TIME WITHOUT TIME ZONE | TIME | DATE | time | |||
TIME WITH TIME ZONE | TIME_WITH_TIMEZONE | DATE | time | |||
TIMESTAMP WITHOUT TIME ZONE | TIMESTAMP | TIMESTAMP | timestamp | |||
TIMESTAMP WITH TIME ZONE | TIMESTAMP_WITH_TIMEZONE | TIMESTAMP | timestamp | |||
INTERVAL | × |
其中Oracle数据类型,参见https://my.oschina.net/jixiaolei/blog/4816208