列数据类型 [英] Column data type

查看:101
本文介绍了列数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,该应用程序必须在运行时加载用于不同任务的各种H2数据库文件,并且必须能够验证加载的DB是否符合预定义的架构.我的意思是,我查询信息架构以检查是否存在特定的表,以及这些表是否包含正确定义的列(例如,数据类型,长度,索引等).

I have an application that has to load various H2 database files for different tasks at runtime and must be able to verify that the loaded DB conforms to a predefined schema. By this I mean that I query the information schema to check whether specific tables are present and whether these tables contain properly defined columns (eg data type, length, indexes etc).

我的问题是关于H2的内部数据类型以及它们如何映射到INFORMATION_SCHEMA.COLUMNS中列出的值.例如,我是否正确,此表中的data_type列正确反映了在创建表期间给出的列数据类型,例如

My question is concerning H2's internal data types and how they map to values listed in INFORMATION_SCHEMA.COLUMNS. For example am I correct that the data_type column in this table properly reflects a columns data type as given during table creation eg

CREATE TABLE test (id int primary key, some_string varchar(32) ... )

将int映射为4的数据类型?是否有数据类型到内部代码的映射的列表,并且这些代码会发生变化吗?

the int is mapped to a data type of 4? Is there a listing of the mappings of the data types to internal codes and do these ever change?

推荐答案

INFORMATION_SCHEMA.COLUMNS中的列DATA_TYPE映射到方法 java.sql.Types .常量 4表示INTEGER .

The column DATA_TYPE in the table table INFORMATION_SCHEMA.COLUMNS is mapped to column 5 (DATA_TYPE) of the method DatabaseMetaData.getColumns. Per specification this is required to be an integer, as defined in java.sql.Types. The constant 4 means INTEGER.

这是JDBC标准的一部分,不会改变.

This is part of the JDBC standard and is not going to change.

这篇关于列数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆