【问题标题】:How can I view the metadata for a Microsoft Access 2013 table?如何查看 Microsoft Access 2013 表的元数据?
【发布时间】:2014-08-26 21:10:23
【问题描述】:

如何查看 Microsoft Access 2013 表的元数据(数据字典)?

【问题讨论】:

    标签: ms-access ms-access-2013 database-metadata


    【解决方案1】:

    如果您想检索访问数据库元数据,这可能会有所帮助:

    每个 microsoft access 数据库都包含一个名为 MSysObjects 的系统表。此表包含此数据库元数据。您可以获取所有具有创建日期和最后更新日期的对象。

    您可以使用以下查询列出 Access 数据库中的所有对象:

    SELECT Name, DateCreate, DateUpdate,   
     iif(LEFT(Name, 4) = 'MSys','System Table', 
     iif(type = 2,'System Object',  
     iif(type = 3,'System Object', 
     iif(type = 8,'System Object',  
     iif(type = 4,'Linked Table (ODBC)', 
     iif(type = 1,'Table',  
     iif(type = 6, 'Linked Table (MsAccess/MsExcel)', 
     iif(type = 5,'Query',  
     iif(type = -32768,'Form', 
     iif(type = -32764,'Report',  
     iif(type=-32766,'Macro', 
     iif(type = -32761,'Module',  
     iif(type = -32756,'Page',  
     iif(type = -32758,'User','Unknown')))))))))))))) as ObjectType 
      FROM MSysObjects WHERE LEFT(Name, 1) <> '~' 
    

    如果您不想显示系统对象,可以将这些条件添加到 where 子句:

    AND LEFT(Name, 4) <> 'MSys' AND Type IN (1, 5, 4, 6,  -32768, -32764, -32766, -32761,-32756,-32758)
    

    我还创建了一个从 access 数据库中检索数据的应用程序,我为它创建了一个新的 Git-repository

    【讨论】:

      【解决方案2】:

      使用 VBA,DAO.TableDef 对象可能会对您有所帮助:

      dim db as DAO.Database, tbl as DAO.TableDef
      dim f as DAO.Field
      set db = currentdb() ' Connect to current database
      
      ' Loop through each table in the database
      for each tbl in db.tableDefs
          debug.print "Table name: ", tbl.Name
          ' Loop throuth each field in the table
          for each f in tbl.Fields
              debug.print "Field: ", f.Name
          next f
      next tbl
      

      这是相当简化的,但您可以获得表及其字段的所有属性。

      检查:

      【讨论】:

        【解决方案3】:

        在 Access 2007 及更高版本(2007、2010、2013)中,“数据库记录器”位于“数据库工具”选项卡下的“分析”组中。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2023-03-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多