代码之家  ›  专栏  ›  技术社区  ›  char m

如何在c/(ado?)中查询(oracle)数据库表结构.NET 2

  •  1
  • char m  · 技术社区  · 15 年前

    我想获取所有表列的表元数据。比如字符串类型(varchar2)/int/float/datetime和字符串长度等等。

    干杯!-马蒂

    2 回复  |  直到 15 年前
        1
  •  3
  •   Thomas Levesque    15 年前

    对于您可以访问的所有表:

    select * from all_tab_columns
    

    对于当前架构中的所有表:

    select * from user_tab_columns
    

    这是特定于Oracle的,但是有一种更通用的方法来检索模式信息: DbConnection.GetSchema 方法:

    schema_owner = "the_owner"; // or null
    table_name = "the_table"; // or null
    column_name = "the_column"; // or null
    DataTable columns = connection.GetSchema("Columns", new string[] { schema_owner, table_name, column_name });
    

    结果表包含与条件匹配的所有可用列信息。

    对于所有可用架构元数据的列表,可以调用 GetSchema 具有 DbMetaDataCollectionNames.MetaDataCollections 作为参数。

        2
  •  1
  •   Jakob Christensen    15 年前

    你可以使用 GetSchema 方法 OracleConnection 班级。