`
deepfuture
  • 浏览: 4340818 次
  • 性别: Icon_minigender_1
  • 来自: 湛江
博客专栏
073ec2a9-85b7-3ebf-a3bb-c6361e6c6f64
SQLite源码剖析
浏览量:79510
1591c4b8-62f1-3d3e-9551-25c77465da96
WIN32汇编语言学习应用...
浏览量:68563
F5390db6-59dd-338f-ba18-4e93943ff06a
神奇的perl
浏览量:101699
Dac44363-8a80-3836-99aa-f7b7780fa6e2
lucene等搜索引擎解析...
浏览量:281627
Ec49a563-4109-3c69-9c83-8f6d068ba113
深入lucene3.5源码...
浏览量:14651
9b99bfc2-19c2-3346-9100-7f8879c731ce
VB.NET并行与分布式编...
浏览量:65823
B1db2af3-06b3-35bb-ac08-59ff2d1324b4
silverlight 5...
浏览量:31400
4a56b548-ab3d-35af-a984-e0781d142c23
算法下午茶系列
浏览量:45307
社区版块
存档分类
最新评论

matlab-数据库元信息

 
阅读更多


dmd


Construct database metadata object
Syntax


dbmeta = dmd(conn)

Description


dbmeta = dmd(conn) constructs a database metadata object for the database connection conn. Use get and supports to obtain properties of dbmeta. Use dmd and get(dbmeta) to obtain information you need about a database, such as table names required to retrieve data.

For a list of functions that operate on database metadata objects, enter:
help dmd/Contents


Examples


dbmeta = dmd(conn) creates a database metadata object dbmeta for the database connection conn.

v = get(dbmeta) lists properties of the database metadata object.

 

=================================
supports


Detect whether property is supported by database metadata object
Syntax


a = supports(dbmeta)
a = supports(dbmeta, 'property')
a.property

Description


a = supports(dbmeta) returns a structure that contains the properties of dbmeta and its property values, 1 or 0. A value of 1 indicates that the property is supported, and 0 indicates that the property is not supported.

a = supports(dbmeta, 'property') returns 1 or 0 for the property field of dbmeta. A value of 1 indicates that the property is supported, and 0 indicates that the property is not supported.

a.property returns the value of property after you have created a using the supports function.
Examples


Check if dbmeta supports group-by clauses.
a = supports(dbmeta, 'GroupBy')
a =
     1

 

View the value of all properties of dbmeta.
a = supports(dbmeta)

 

The returned result is a list of properties and their values.

See the value of the GroupBy property by running:
a.GroupBy
a =
     1

 

===============================

 


tables


Return database table names
Syntax


t = tables(dbmeta, 'cata')
t = tables(dbmeta, 'cata', 'sch')

Description


t = tables(dbmeta, 'cata') returns a list of tables and table types in the catalog cata, for the database whose database metadata object is dbmeta.

t = tables(dbmeta, 'cata', 'sch') returns a list of tables and table types in:

The schema sch

Of the catalog cata

For the database whose database metadata object is dbmeta

 

Tip   For command-line help on tables, use the overloaded method:
help dmd/tables


Examples


Get the table names and types for the schema SCOTT in the catalog orcl, for the database metadata object dbmeta.
t = tables(dbmeta,'orcl', 'SCOTT')
t =
    'BONUS'       'TABLE'
    'DEPT'        'TABLE'
    'EMP'         'TABLE'
    'SALGRADE'    'TABLE'
    'TRIAL'       'TABLE'

上机 操作

>> myconn=database('students','mytest','deepfuture','com.mysql.jdbc.Driver','jdbc:mysql://localhost:3306/students')
 
myconn =
 
       Instance: 'students'
       UserName: 'mytest'
         Driver: 'com.mysql.jdbc.Driver'
            URL: 'jdbc:mysql://localhost:3306/students'
    Constructor: [1x1 com.mathworks.toolbox.database.databaseConnect]
        Message: []
         Handle: [1x1 com.mysql.jdbc.JDBC4Connection]
        TimeOut: 0
     AutoCommit: 'on'
           Type: 'Database Object'

>> mydbmetaa=dmd(myconn)
 
mydbmetaa =
 
    DMDHandle: [1x1 com.mysql.jdbc.JDBC4DatabaseMetaData]

 

>> myv=get(mydbmetaa)

myv =

                 AllProceduresAreCallable: 0
                   AllTablesAreSelectable: 0
    DataDefinitionCausesTransactionCommit: 1
      DataDefinitionIgnoredInTransactions: 0
               DoesMaxRowSizeIncludeBlobs: 1
                                 Catalogs: {3x1 cell}
                         CatalogSeparator: '.'
                              CatalogTerm: 'database'
                      DatabaseProductName: 'MySQL'
                   DatabaseProductVersion: '5.5.25a'
              DefaultTransactionIsolation: 2
                       DriverMajorVersion: 5
                       DriverMinorVersion: 1
                               DriverName: 'MySQL-AB JDBC Driver'
                            DriverVersion: [1x60 char]
                      ExtraNameCharacters: '#@'
                    IdentifierQuoteString: '`'
                         IsCatalogAtStart: 1
                   MaxBinaryLiteralLength: 16777208
                     MaxCatalogNameLength: 32
                     MaxCharLiteralLength: 16777208
                      MaxColumnNameLength: 64
                      MaxColumnsInGroupBy: 64
                        MaxColumnsInIndex: 16
                      MaxColumnsInOrderBy: 64
                       MaxColumnsInSelect: 256
                        MaxColumnsInTable: 512
                           MaxConnections: 0
                      MaxCursorNameLength: 64
                           MaxIndexLength: 256
                   MaxProcedureNameLength: 0
                               MaxRowSize: 2.1475e+009
                      MaxSchemaNameLength: 0
                       MaxStatementLength: 65531
                            MaxStatements: 0
                       MaxTableNameLength: 64
                        MaxTablesInSelect: 256
                        MaxUserNameLength: 16
                         NumericFunctions: [1x144 char]
                            ProcedureTerm: 'PROCEDURE'
                                  Schemas: {}
                               SchemaTerm: ''
                       SearchStringEscape: '\'
                              SQLKeywords: [1x1116 char]
                          StringFunctions: [1x374 char]
               StoresLowerCaseIdentifiers: 1
         StoresLowerCaseQuotedIdentifiers: 1
               StoresMixedCaseIdentifiers: 0
         StoresMixedCaseQuotedIdentifiers: 0
               StoresUpperCaseIdentifiers: 0
         StoresUpperCaseQuotedIdentifiers: 1
                          SystemFunctions: [1x78 char]
                               TableTypes: {3x1 cell}
                        TimeDateFunctions: [1x289 char]
                                 TypeInfo: {40x1 cell}
                                      URL: [1x36 char]
                                 UserName: 'mytest@localhost'
                    NullPlusNonNullIsNull: 1
                      NullsAreSortedAtEnd: 0
                    NullsAreSortedAtStart: 0
                       NullsAreSortedHigh: 0
                        NullsAreSortedLow: 1
                    UsesLocalFilePerTable: 0
                           UsesLocalFiles: 0

数据库项目(包含的数据库)

>> myv.Catalogs

ans =

    'information_schema'
    'students'
    'test'

>>

元数据对象支持和不支持的属性

>> mys=supports(mydbmetaa)

mys =

                          AlterTableWithAddColumn: 1
                         AlterTableWithDropColumn: 1
                              ANSI92EntryLevelSQL: 1
                                    ANSI92FullSQL: 0
                            ANSI92IntermediateSQL: 0
                       CatalogsInDataManipulation: 1
                       CatalogsInIndexDefinitions: 1
                   CatalogsInPrivilegeDefinitions: 1
                         CatalogsInProcedureCalls: 1
                       CatalogsInTableDefinitions: 1
                                   ColumnAliasing: 1
                                          Convert: 0
                                   CoreSQLGrammar: 1
                             CorrelatedSubqueries: 1
    DataDefinitionAndDataManipulationTransactions: 0
                 DataManipulationTransactionsOnly: 0
                   DifferentTableCorrelationNames: 1
                             ExpressionsInOrderBy: 1
                               ExtendedSQLGrammar: 0
                                   FullOuterJoins: 0
                                          GroupBy: 1
                              GroupByBeyondSelect: 1
                                 GroupByUnrelated: 1
                     IntegrityEnhancementFacility: 0
                                 LikeEscapeClause: 1
                                LimitedOuterJoins: 1
                                MinimumSQLGrammar: 1
                             MixedCaseIdentifiers: 0
                       MixedCaseQuotedIdentifiers: 0
                               MultipleResultSets: 1
                             MultipleTransactions: 1
                               NonNullableColumns: 1
                          OpenCursorsAcrossCommit: 0
                        OpenCursorsAcrossRollback: 0
                       OpenStatementsAcrossCommit: 0
                     OpenStatementsAcrossRollback: 0
                                 OrderByUnrelated: 0
                                       OuterJoins: 1
                                 PositionedDelete: 0
                                 PositionedUpdate: 0
                        SchemasInDataManipulation: 0
                        SchemasInIndexDefinitions: 0
                    SchemasInPrivilegeDefinitions: 0
                          SchemasInProcedureCalls: 0
                        SchemasInTableDefinitions: 0
                                  SelectForUpdate: 1
                                 StoredProcedures: 1
                          SubqueriesInComparisons: 1
                               SubqueriesInExists: 1
                                  SubqueriesInIns: 1
                          SubqueriesInQuantifieds: 1
                            TableCorrelationNames: 1
                                     Transactions: 1
                                            Union: 1
                                         UnionAll: 1

某个数据库包含的表

>> tables(mydbmetaa,'students')

ans =

    'student'    'TABLE'

>>  

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics