java.sql.DatabaseMetaData
is an interface that defines database objects.
Description
This interface provides comprehensive information about the entire database. It is implemented by driver vendors and enables users to learn about the features available after Database Management System (DBMS) is used in combination with the Java Database Connectivity (JDBC) driver. Note that the term "database" used in this documentation refer to both the driver and DBMS.
This interface is commonly used as a tool that deals with the underlying DBMS. For example, the getTypeInfo
method may be used to find out the data types that can be used in a CREATE TABLE
statement. Alternatively, a user may call the supportsCorrelatedSubqueries
method to check whether a correlated subquery can be used, or call the supportsBatchUpdates
method to check whether batch updates are supported.
Some DatabaseMetaData
methods return lists of information in the form of ResultSet objects. Regular ResultSet methods, such as getString
and getInt
, can be used to retrieve data from these ResultSet objects. If metadata in a given form is unavailable, an empty ResultSet
will be returned. Except the columns defined to be returned by the ResultSet object for a given method, other columns can be defined by the JDBC driver vendor and must be accessed by their column label.
Some DatabaseMetaData methods take parameters in String patterns. In a String pattern, "%" indicates to match any substring of zero or more characters, and "_" indicates to match any one character. For a search pattern, only metadata entries that match the search pattern are returned. If the search pattern parameter is set to null
, the criteria of the parameter will be dropped from the search.
Methods
Method | Return type | Supported in Oracle mode? | Supported in MySQL mode? |
---|---|---|---|
getImportedKeys(String catalog,String schema,String table) | ResultSet | Yes | Yes |
getPrimaryKeys(String catalog,String schema,String table) | ResultSet | Yes | Yes |
getTables(String catalog,String schemaPattern,String tableNamePattern,String types[]) | ResultSet | Yes | Yes |
getColumns(String catalog,String schemaPattern,String tableNamePattern,String columnNamePattern) | ResultSet | Yes | Yes |
getExportedKeys(String catalog,String schema,String table) | ResultSet | Yes | Yes |
getBestRowIdentifier(String catalog, String schema,String table, int scope, boolean nullable) | ResultSet | Yes | Yes |
getPseudoColumns(String catalog, String schemaPattern,String tableNamePattern, String columnNamePattern) | ResultSet | Yes | Yes |
getURL() | String | Yes | Yes |
getUserName() | String | Yes | Yes |
getDatabaseProductName() | String | Yes | Yes |
getSQLKeywords() | String | Yes | Yes |
getNumericFunctions() | String | Yes | Yes |
getStringFunctions() | String | Yes | Yes |
getSystemFunctions() | String | Yes | Yes |
getTimeDateFunctions() | String | Yes | Yes |
supportsConvert() | Boolean | Yes | Yes |
getProcedures(String catalog,String schemaPattern,String procedureNamePattern) | ResultSet | Yes | Yes |
getProcedureColumns(String catalog,String schemaPattern,String procedureNamePattern,String columnNamePattern) | ResultSet | Yes | Yes |
getFunctionColumns(String catalog,String schemaPattern,String procedureNamePattern,String columnNamePattern) | ResultSet | Yes | Yes |
getSchemas() | ResultSet | Yes | Yes |
getSchemas(String catalog,String schemaPattern) | ResultSet | Yes | Yes |
getCatalogs() | ResultSet | Yes | Yes |
getTableTypes() | ResultSet | Yes | Yes |
getColumnPrivileges(String catalog,String schema,String table,String columnNamePattern) | ResultSet | Yes | Yes |
getTablePrivileges(String catalog,String schemaPattern,String tableNamePattern) | ResultSet | Yes | Yes |
getVersionColumns(String catalog,String schema,String table) | ResultSet | Yes | Yes |
getCrossReference(String parentCatalog,String parentSchema,String parentTable,String foreignCatalog,String foreignSchema,String foreignTable ) | ResultSet | Yes | Yes |
getTypeInfo() | ResultSet | Yes | Yes |
getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) | ResultSet | Yes | Yes |
getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) | ResultSet | Yes | Yes |
getSuperTypes(String catalog,String schemaPattern,String typeNamePattern) | ResultSet | Yes | Yes |
getSuperTables(String catalog,String schemaPattern,String tableNamePattern) | ResultSet | Yes | Yes |
getClientInfoProperties() | ResultSet | Yes | Yes |
getFunctions(String catalog,String schemaPattern,String functionNamePattern) | ResultSet | Yes | Yes |
getAttributes(String catalog,String schemaPattern,String typeNamePattern,String attributeNamePattern) | ResultSet | Yes | Yes |