接口 DatabaseMetaData.getColumns

接口 DatabaseMetaData.getColumns来源:http://docs.oracle.com/javase/1.4.2/docs/api/java/sql/DatabaseMetaData.html#getColumns(java.lang.String,java.lang.String,java.lang.String,java.lang.String)http://www.cjsdn.net/doc/jdk50/

大家好,又见面了,我是你们的朋友全栈君。

来源:

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_SCHEMTABLE_NAME, and ORDINAL_POSITION.

Each column description has the following columns:

  1. TABLE_CAT String => table catalog (may be null)
  2. TABLE_SCHEM String => table schema (may be null)
  3. TABLE_NAME String => table name
  4. COLUMN_NAME String => column name
  5. DATA_TYPE int => SQL type from java.sql.Types
  6. TYPE_NAME String => Data source dependent type name, for a UDT the type name is fully qualified
  7. 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.
  8. BUFFER_LENGTH is not used.
  9. DECIMAL_DIGITS int => the number of fractional digits
  10. NUM_PREC_RADIX int => Radix (typically either 10 or 2)
  11. NULLABLE int => is NULL allowed.
    • columnNoNulls – might not allow NULL values
    • columnNullable – definitely allows NULL values
    • columnNullableUnknown – nullability unknown
  12. REMARKS String => comment describing column (may be null)
  13. COLUMN_DEF String => default value (may be null)
  14. SQL_DATA_TYPE int => unused
  15. SQL_DATETIME_SUB int => unused
  16. CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column
  17. ORDINAL_POSITION int => index of column in table (starting at 1)
  18. 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.
  19. SCOPE_CATLOG String => catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn’t REF)
  20. SCOPE_SCHEMA String => schema of table that is the scope of a reference attribute (null if the DATA_TYPE isn’t REF)
  21. SCOPE_TABLE String => table name that this the scope of a reference attribure (null if the DATA_TYPE isn’t REF)
  22. 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)
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 search
schemaPattern – 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 search
tableNamePattern – a table name pattern; must match the table name as it is stored in the database
columnNamePattern – 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_SCHEMTABLE_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()

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/151007.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 二维数组a[3][4]_树状数组和线段树的区别

    二维数组a[3][4]_树状数组和线段树的区别原题链接堆栈是一种经典的后进先出的线性结构,相关的操作主要有“入栈”(在堆栈顶插入一个元素)和“出栈”(将栈顶元素返回并从堆栈中删除)。本题要求你实现另一个附加的操作:“取中值”——即返回所有堆栈中元素键值的中值。给定 N 个元素,如果 N 是偶数,则中值定义为第 N/2 小元;若是奇数,则为第 (N+1)/2 小元。输入格式:输入的第一行是正整数 N(≤10​5​​ )。随后 N 行,每行给出一句指令,为以下 3 种之一:Push keyPopPeekMedian其中 key 是不超过

    2022年8月8日
    4
  • set跟map的区别_oracle set用法

    set跟map的区别_oracle set用法1.Map是键值对,Set是值的集合,当然键和值可以是任何的值;2.Map可以通过get方法获取值,而set不能因为它只有值;3.都能通过迭代器进行for…of遍历;4.Set的值是唯一的可以做数组去重,Map由于没有格式限制,可以做数据存储5.map和set都是stl中的关联容器,map以键值对的形式存储,key=value组成pair,是一组映射关系。set只有值,可以认为只有一个数据,并且set中元素不可以重复且自动排序。SetSet对象允许你存储任何类型的值,无论.

    2022年9月6日
    5
  • python敏感词过滤代码简单(敏感词匹配算法)

    今天游戏正好用到需要过滤敏感词将出现的敏感词替换成*,在网上找了许久找了一片可用的java版本的DFA算法,最后费了一番功夫将其思路用C#实现,里面的注释甚至都没改动的,这里直接上代码,这里不借助任何第三方工具,复制粘贴就是用当然想看原博客的点击这里usingUnityEngine;usingSystem.Collections.Generic;publicclassTes…

    2022年4月17日
    160
  • Python-opencv读取深度图像

    Python-opencv读取深度图像由于实验需要用到Kinect2.0采集的深度图像,但是用以下程序读取深度图片的时候显不方便观察temp_img=’cup_depth.png’depth_filename=os.path.join(image_dir,depth_img)temp_filename=os.path.join(image_dir,temp_img)im…

    2022年5月24日
    206
  • Linux 5nd Day

    Linux 5nd Day

    2021年8月7日
    53
  • 可视化报表开发_可视化数据报表

    可视化报表开发_可视化数据报表当今时代,传统的报表工具已经很难满足人们对于数据可视化的期望了,而大数据处理工具却可以为人们提供了更多的选择。微金时代的RDP报表工具操作简便,可直接上手使用,无需编码,就可以制作各种复杂、炫酷的报表。RDP报表工具表格式报表功能和亮点根据中国特色的报表需求,研发出的轻量级的企业级Web报表工具。仅需简单拖拽式配置,即可制作出各种复杂、炫酷的报表。支持中国式复杂报表的处理,例如:Excel清单报表、交叉报表、分组报表、多源分片式报表、分块报表、表单报表、图形报表、回写报表、假设分析报表、二次.

    2022年10月2日
    4

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号