getVersionColumns 方法 (SQLServerDatabaseMetaData)getVersionColumns Method (SQLServerDatabaseMetaData)

下载下载 JDBC 驱动程序DownloadDownload JDBC Driver

检索在某行内的任何值更新时会随之自动更新的表列的说明。Retrieves a description of the columns of a table that is automatically updated when any value in a row is updated.

语法Syntax

  
public java.sql.ResultSet getVersionColumns(java.lang.String catalog,  
                                            java.lang.String schema,  
                                            java.lang.String table)  

parametersParameters

catalogcatalog

一个包含目录名称的字符串 。A String that contains the catalog name.

schemaschema

一个包含架构名称模式的字符串 。A String that contains the schema name pattern.

tabletable

一个包含表名称的字符串 。A String that contains the table name.

返回值Return Value

一个 SQLServerResultSet 对象。A SQLServerResultSet object.

例外Exceptions

SQLServerExceptionSQLServerException

备注Remarks

此 getVersionColumns 方法是由 java.sql.DatabaseMetaData 接口中的 getVersionColumns 方法指定的。This getVersionColumns method is specified by the getVersionColumns method in the java.sql.DatabaseMetaData interface.

由 getVersionColumns 方法返回的结果集将包含下列信息:The result set returned by the getVersionColumns method will contain the following information:

名称Name 类型Type 说明Description
SCOPESCOPE shortshort JDBC 驱动程序不支持此类型。Not supported by the JDBC driver.
COLUMN_NAMECOLUMN_NAME 字符串String 列名称。The column name.
DATA_TYPEDATA_TYPE shortshort 来自 java.sql.Types 的 SQL 数据类型。The SQL data type from java.sql.Types.
TYPE_NAMETYPE_NAME 字符串String 数据类型的名称。The name of the data type.
COLUMN_SIZECOLUMN_SIZE intint 列的精度。The precision of the column.
BUFFER_LENGTHBUFFER_LENGTH intint 列的长度(字节)。The length of the column in bytes.
DECIMAL_DIGITSDECIMAL_DIGITS shortshort 列的小数位数。The scale of the column.
PSEUDO_COLUMNPSEUDO_COLUMN shortshort 指示列是否为伪列。Indicates if the column is a pseudo column. 可以为下列值之一:It can be one of the following values:

versionColumnUnknown (0)versionColumnUnknown (0)

versionColumnNotPseudo (1)versionColumnNotPseudo (1)

versionColumnPseudo (2)versionColumnPseudo (2)

备注

有关 getVersionColumns 方法返回的数据的详细信息,请参阅 SQL ServerSQL Server 联机丛书中的“sp_datatype_info (Transact-SQL)”。For more information about the data returned by the getVersionColumns method, see "sp_datatype_info (Transact-SQL)" in SQL ServerSQL Server Books Online.

示例Example

以下示例演示了如何使用 getVersionColumns 方法返回 AdventureWorksAdventureWorks 示例数据库中的 Person.Contact 表中自动更新的列的信息。The following example demonstrates how to use the getVersionColumns method to return information about the columns that are automatically updated in the Person.Contact table in the AdventureWorksAdventureWorks sample database.

public static void executeGetVersionColumns(Connection con) {  
   try {  
      DatabaseMetaData dbmd = con.getMetaData();  
      ResultSet rs = dbmd.getVersionColumns("AdventureWorks", "Person", "Contact");  
      ResultSetMetaData rsmd = rs.getMetaData();  
  
      // Display the result set data.  
      int cols = rsmd.getColumnCount();  
      while(rs.next()) {  
         for (int i = 1; i <= cols; i++) {  
            System.out.println(rs.getString(i));  
         }  
      }  
      rs.close();  
   }   
  
   catch (Exception e) {  
      e.printStackTrace();  
   }  
}  

另请参阅See Also

SQLServerDatabaseMetaData 方法 SQLServerDatabaseMetaData Methods
SQLServerDatabaseMetaData 成员 SQLServerDatabaseMetaData Members
SQLServerDatabaseMetaData 类SQLServerDatabaseMetaData Class