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()
最新文章
- HTTP请求应答服务——HTTP Request &; Response Service
- C语言中printf的规范输出
- jquery'中的匿名函数
- IOS基础之 (设计模式)
- 【转】搭建nginx+tomcat+Java的负载均衡环境
- dump java
- 【原】SparkContex源码解读(一)
- iframe页面改动parent页面的隐藏input部件value值,不能触发change事件。
- C++中复制构造函数与重载赋值操作符
- Eclipse编译Arduino程序不能使用串口函数Serial.begin解决办法
- 达内TTS6.0课件oop_day01
- 2014 HDU多校弟五场J题 【矩阵乘积】
- selenium RC
- 刚开始学python——数据结构——“自定义队列结构“
- Maven详解(五)------ 坐标的概念以及依赖管理
- [Swift]LeetCode680. 验证回文字符串 Ⅱ | Valid Palindrome II
- Maven2-坐标
- visio子流程创建
- 114自定义UITableViewCell(扩展知识:为UITableViewCell添加动画效果)
- STM32 LSM6DSL 陀螺仪数据采集
热门文章
- linux端口开放关闭 firewalld 使用
- 【】Elasticsearch客户端API使用Demo
- MyBatis 二级缓存实现详解及使用注意事项
- Pond Skater
- 【Python+Django+Pytest】数据库异常pymysql.err.InterfaceError: (0, '') 解决方案
- LINUX学习--nginx服务器的安装
- FastDFS文件的上传和下载
- 《剑指offer》面试题52. 两个链表的第一个公共节点
- leetcode 102. 二叉树的层次遍历 及 103. 二叉树的锯齿形层次遍历
- leetcode 787. K 站中转内最便宜的航班