This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Display Database Metadata

This example shows how to display database information for connection objects using the command line. To view the database structure quickly, use Database Explorer to explore the tables and column names. Here, metadata refers to the information about the database structure and various database properties.

Create Database Connection

Create a database connection conn using the dbtoolboxdemo data source.

conn = database('dbtoolboxdemo','admin','admin');

Determine if the database connection conn is open.

o = isopen(conn)
o = 


o returns as the scalar 1 that denotes the database connection is open.

Create Database Metadata Object

Create a database metadata object dbmeta using conn.

dbmeta = dmd(conn)
dbmeta = 

  dmd with properties:

    DMDHandle: [1×1 database.internal.ODBCDatabaseMetadataHandle]

Display Database Properties

Display the database properties dbprops of the database metadata object dbmeta.

dbprops = get(dbmeta)
dbprops = 

              AllProceduresAreCallable: 1
                AllTablesAreSelectable: 1
 DataDefinitionCausesTransactionCommit: 1

For details about the database metadata properties returned by get, see the methods of the DatabaseMetaData object on the Oracle® Java® website:

Display the properties props this database supports using dbmeta.

props = supports(dbmeta)
props =

        AlterTableWithAddColumn: 1
       AlterTableWithDropColumn: 1
            ANSI92EntryLevelSQL: 1

A 1 for a given property indicates that the database supports that property. 0 means that the database does not support the property.

For details about properties that the database supports, see the methods of the DatabaseMetaData object on the Oracle Java website:

Retrieve Catalog Metadata

Retrieve the names and types of tables in a catalog in the database using dbmeta and the catalog name tutorial.

t = tables(dbmeta,'tutorial')
t = 

    'MSysAccessObjects'    'SYSTEM TABLE'
    'MSysIMEXColumns'      'SYSTEM TABLE'
    'MSysIMEXSpecs'        'SYSTEM TABLE'
    'MSysObjects'          'SYSTEM TABLE'
    'MSysQueries'          'SYSTEM TABLE'
    'MSysRelationships'    'SYSTEM TABLE'
    'inventoryTable'       'TABLE'       
    'productTable'         'TABLE'       
    'salesVolume'          'TABLE'       
    'suppliers'            'TABLE'       
    'yearlySales'          'TABLE'       
    'display'              'VIEW'        

t contains the list of table names in the catalog in the first column and list of table types in the second column.

Close Database Connection


See Also

| | | | |

Related Examples

More About

Was this topic helpful?