DatabaseMetaData
getColumns
- public ResultSet getColumns(String catalog,
- String schemaPattern,
- String tableNamePattern,
- String columnNamePattern)
- throws SQLException
- Retrieves a description of table columns available in the specified catalog.
Only column descriptions matching the catalog, schema, table and column name criteria are returned. They are ordered by
TABLE_SCHEM
,TABLE_NAME
, andORDINAL_POSITION
.Each column description has the following columns:
- TABLE_CAT String => table catalog (may be
null
) - TABLE_SCHEM String => table schema (may be
null
) - TABLE_NAME String => table name
- COLUMN_NAME String => column name
- DATA_TYPE int => SQL type from java.sql.Types
- TYPE_NAME String => Data source dependent type name, for a UDT the type name is fully qualified
- COLUMN_SIZE int => column size. For char or date types this is the maximum number of characters, for numeric or decimal types this is precision.
- BUFFER_LENGTH is not used.
- DECIMAL_DIGITS int => the number of fractional digits
- NUM_PREC_RADIX int => Radix (typically either 10 or 2)
- NULLABLE int => is NULL allowed.
- columnNoNulls - might not allow
NULL
values - columnNullable - definitely allows
NULL
values - columnNullableUnknown - nullability unknown
- columnNoNulls - might not allow
- REMARKS String => comment describing column (may be
null
) - COLUMN_DEF String => default value (may be
null
) - SQL_DATA_TYPE int => unused
- SQL_DATETIME_SUB int => unused
- CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column
- ORDINAL_POSITION int => index of column in table (starting at 1)
- IS_NULLABLE String => "NO" means column definitely does not allow NULL values; "YES" means the column might allow NULL values. An empty string means nobody knows.
- SCOPE_CATLOG String => catalog of table that is the scope of a reference attribute (
null
if DATA_TYPE isn't REF) - SCOPE_SCHEMA String => schema of table that is the scope of a reference attribute (
null
if the DATA_TYPE isn't REF) - SCOPE_TABLE String => table name that this the scope of a reference attribure (
null
if the DATA_TYPE isn't REF) - SOURCE_DATA_TYPE short => source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types (
null
if DATA_TYPE isn't DISTINCT or user-generated REF)
- TABLE_CAT String => table catalog (may be
-
- Parameters:
catalog
- a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog;null
means that the catalog name should not be used to narrow the searchschemaPattern
- a schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema;null
means that the schema name should not be used to narrow the searchtableNamePattern
- a table name pattern; must match the table name as it is stored in the databasecolumnNamePattern
- a column name pattern; must match the column name as it is stored in the database- Returns:
ResultSet
- each row is a column description- Throws:
SQLException
- if a database access error occurs- See Also:
getSearchStringEscape()
getColumns
- ResultSet getColumns(String catalog,
- String schemaPattern,
- String tableNamePattern,
- String columnNamePattern)
- throws SQLException
- 检索可在指定类别中使用的表列的描述。
仅返回与类别、模式、表和列名称标准匹配的列描述。它们根据
TABLE_SCHEM
、TABLE_NAME
和ORDINAL_POSITION
进行排序。每个列描述都有以下列:
TABLE_CAT String => 表类别(可为
null
)
TABLE_SCHEM String => 表模式(可为null
)
TABLE_NAME String => 表名称
COLUMN_NAME String => 列名称
DATA_TYPE int => 来自 java.sql.Types 的 SQL 类型
TYPE_NAME String => 数据源依赖的类型名称,对于 UDT,该类型名称是完全限定的
COLUMN_SIZE int => 列的大小。对于 char 或 date 类型,列的大小是最大字符数,对于 numeric 和 decimal 类型,列的大小就是精度。
BUFFER_LENGTH 未被使用。
DECIMAL_DIGITS int => 小数部分的位数
NUM_PREC_RADIX int => 基数(通常为 10 或 2)
NULLABLE int => 是否允许使用 NULL。columnNoNulls - 可能不允许使用NULL
值
columnNullable - 明确允许使用NULL
值
columnNullableUnknown - 不知道是否可使用 null
REMARKS String => 描述列的注释(可为null
)
COLUMN_DEF String => 默认值(可为null
)
SQL_DATA_TYPE int => 未使用
SQL_DATETIME_SUB int => 未使用
CHAR_OCTET_LENGTH int => 对于 char 类型,该长度是列中的最大字节数
ORDINAL_POSITION int => 表中的列的索引(从 1 开始)
IS_NULLABLE String => "NO" 表示明确不允许列使用 NULL 值,"YES" 表示可能允许列使用 NULL 值。空字符串表示没人知道是否允许使用 null 值。
SCOPE_CATLOG String => 表的类别,它是引用属性的作用域(如果 DATA_TYPE 不是 REF,则为null
)
SCOPE_SCHEMA String => 表的模式,它是引用属性的作用域(如果 DATA_TYPE 不是 REF,则为null
)
SCOPE_TABLE String => 表名称,它是引用属性的作用域(如果 DATA_TYPE 不是 REF,则为null
)
SOURCE_DATA_TYPE short => 不同类型或用户生成 Ref 类型、来自 java.sql.Types 的 SQL 类型的源类型(如果 DATA_TYPE 不是 DISTINCT 或用户生成的 REF,则为null
) -
- 参数:
catalog
- 类别名称,因为存储在数据库中,所以它必须匹配类别名称。该参数为 "" 则检索没有类别的描述,为null
则表示该类别名称不应用于缩小搜索范围schemaPattern
- 模式名称的模式,因为存储在数据库中,所以它必须匹配模式名称。该参数为 "" 则检索那些没有模式的描述,为null
则表示该模式名称不应用于缩小搜索范围tableNamePattern
- 表名称模式,因为存储在数据库中,所以它必须匹配表名称columnNamePattern
- 列名称模式,因为存储在数据库中,所以它必须匹配列名称- 返回:
ResultSet
- 每一行都是一个列描述- 抛出:
SQLException
- 如果发生数据库访问错误- 另请参见:
getSearchStringEscape()
DatabaseMetaData的更多相关文章
- ResultSetMetaData和DatabaseMetaData实现数据库中属性,属性值,属性所赋值的获取等
----------------------------------------------有些类下面代码中有; public class Test1 { TestDAO t=new TestDAO( ...
- DatabaseMetaData的用法【转载】
一 . 得到这个对象的实例Connection con ;con = DriverManager.getConnection(url,userName,password);DatabaseMetaDa ...
- JDBC 元数据 (DatabaseMetaData,ResultSetMetaData )
Java 通过JDBC获得连接以后,得到一个Connection 对象,可以从这个对象获得有关数据库管理系统的各种信息,包括数据库中的各个表,表中的各个列,数据类型,触发器,存储过程等各方面的信息.根 ...
- JDBC(5)—DatabaseMetaData
1.简介: 使用元数据已实现通用的查询方法.元数据介绍:使用jdbc获得连接之后,得到一个Connection对象,可以通过这个对象获得DataBaseMetaData对象,该对象可以获得有关数据库管 ...
- java 查询oracle数据库所有表DatabaseMetaData的用法
DatabaseMetaData的用法(转) 一 . 得到这个对象的实例 Connection con ; con = DriverManager.getConnection(url,userName ...
- JDBC(5)ResSetMetaData&DatabaseMetaData&获取数据库主键的值
ResSetMetaData 可用于获取关于 ResultSet 对象中列的类型和属性信息的对象: getColumnName(int column):获取指定列的名称 getColumnCount( ...
- 根据DatabaseMetaData确定数据库类型
根据DatabaseMetaData确定数据库类型 DataSource dataSource = dataSourceTransactionManager.getDataSource(); conn ...
- DatabaseMetaData类
DatabaseMetaData类是java.sql包中的类,利用它可以获取我们连接到的数据库的结构.存储等很多信息.如: 1.数据库与用户,数据库标识符以及函数与存储过程. 2.数据 ...
- DatabaseMetaData开发实务
1.总论 在企业开发实务中,数据迁移是经常会遇到的事情,此时,需要搞清楚,源数据库与目的数据库之间表以及表内部各列之间的异同.而有些时候,我们拿到的项目文 档,未必能准确表述各个表的准确结构,即使应用 ...
- OpenJDK源码研究笔记(十二):JDBC中的元数据,数据库元数据(DatabaseMetaData),参数元数据(ParameterMetaData),结果集元数据(ResultSetMetaDa
元数据最本质.最抽象的定义为:data about data (关于数据的数据).它是一种广泛存在的现象,在许多领域有其具体的定义和应用. JDBC中的元数据,有数据库元数据(DatabaseMeta ...
随机推荐
- SpringCloud创建Eureka模块集群
1.说明 本文详细介绍Spring Cloud创建Eureka模块集群的方法, 基于已经创建好的Spring Cloud Eureka Server模块, 请参考SpringCloud创建Eureka ...
- html基础 有语义的布局标签
- Git_使用SSH密钥操作远端仓库
git支持多种传输协议,ssh协议是其中一种. 初次使用git的用户要使用ssh协议大概需要三个步骤: 生成密钥 设置远程仓库(本文以github为例)上的公钥 把git的 remote url 修改 ...
- Go 中实现用户的每日限额(比如一天只能领三次福利)
如果你写一个 bug 管理系统,用了这个 PeriodLimit 你就可以限制每个测试人员每天只能给你提一个 bug.工作是不是就轻松很多了? 如今微服务架构大行其道本质原因是因为要降低系统的整体复杂 ...
- 在asp.net webfrom 中完成用户自定义导出
asp.net原生控件实现自定义列导出功能 自定义列实现 最近负责开发公司内部使用的人事信息化系统时,有一个需求是这样的,需要在页面中可以用户每次导出Excel时自定义需要导出哪些列,经过半天的琢磨和 ...
- class、抽象类、接口区别
Java 抽象类 在面向对象的概念中,所有的对象都是通过类来描绘的,但是反过来,并不是所有的类都是用来描绘对象的,如果一个类中没有包含足够的信息来描绘一个具体的对象,这样的类就是抽象类. 由于抽象类不 ...
- 《剑指offer》面试题38. 字符串的排列
问题描述 输入一个字符串,打印出该字符串中字符的所有排列. 你可以以任意顺序返回这个字符串数组,但里面不能有重复元素. 示例: 输入:s = "abc" 输出:["abc ...
- mysql数据库优化1
目录 数据库结构的设计优化 1.数据库结构的设计 2.针对大型的数据量提前进行分库和分表 3.分库分表带来的问题 4.表结构设计注意的问题 查询优化 1.查询语句的注意事项 2.应尽量避免在 wher ...
- 内核内存分配器SLAB和SLUB
内核分配器的功能 在操作系统管理的虚拟内存中,用于内存管理的最小单位是页,大多数传统的架构是4KB.由于进程每次申请分配4KB是不现实的,比如分配几个字节或几十个字节,这时需要中间机制来管理页面的微型 ...
- 一种Django多租户解决方案
什么是多租户? 多租户技术或称多重租赁技术,简称SaaS,是一种软件架构技术,是实现如何在多用户环境下(此处的多用户一般是面向企业用户)共用相同的系统或程序组件,并且可确保各用户间数据的隔离性. 多租 ...