zoukankan      html  css  js  c++  java
  • 外键表 主键表

    /// <summary>
            /// 查询方法
            /// </summary>
            /// <param name="tabNames">TableName</param>
            /// <returns>数据集</returns>
            public DataSet Query(string tabNames,string columnName)
            {
                using (OracleHelper orahp = new OracleHelper())
                {
                    string[] tabs = tabNames.Split(',');
                    DataSet data = new DataSet();
                    orahp.Open();
                    for (int i = 0; i < tabs.Length; i++)
                    {
                        string tabTemp = tabs[i];
                        string sql = "select NVL(v.外键表,'" + tabTemp + "') as 外键表,ac.column_name 列名,ac.data_type 类型,ac.data_length 长度,v.主键表,v.主键列,p.主键列 PK,v.多选,ac.NULLABLE from ";
                        sql += "(select s.table_name,s.COLUMN_NAME,s.data_type,s.data_length,s.NULLABLE from all_tab_columns s where ";
                        if (columnName.Length > 0)
                            sql += "s.column_name='" + columnName + "'";
                        else
                            sql+="s.column_name<>'OBJECTID'";
                        sql+=" and s.owner='"+ dbOwner +"' and s.TABLE_NAME='"+tabTemp+"') ac";
                        sql += " left outer join (select * from view_fk where 外键表='"+ tabTemp +"') v on v.外键列=ac.column_name";
                        sql += " left outer join (select * from view_pk where 表名='" + tabTemp + "') p on ac.COLUMN_NAME=p.主键列";
                        if (columnName.Length < 1)
                        sql += " union select v.外键表,v.外键列 as 列名,'NVARCHAR2' as 类型,100 as 长度,v.主键表,v.主键列,null as PK,v.多选,'N' as NULLABLE from(select * from view_fk where 主键表='" + tabTemp + "') v";

                        OracleCommand comd = new OracleCommand(sql);
                        DataTable dataTab = new DataTable();
                        dataTab.TableName = tabTemp;
                        if (data.Tables.Contains(tabTemp))
                            continue;
                        orahp.Execute(comd, dataTab);
                        //data.Tables.Add(dataTab);
                        data = ChangeDt(dataTab);
                    }
                    orahp.Close();

                    return data;
                }
            }

  • 相关阅读:
    远程连接Ubuntu中的MySQL
    以API 配置的方式来配置你的 Dubbo 应用
    jdk1.8:stream流式分组groupby
    springboot如何通过apollo动态去注册dubbo服务
    JDK动态代理[3]WeakCache缓存的实现机制
    Linq 交集、并集等集合理论学习
    Build my first Blazor app
    关于
    MySql数据库优化维度
    面霸篇:Java 集合容器大满贯(卷二)
  • 原文地址:https://www.cnblogs.com/threestone/p/1714797.html
Copyright © 2011-2022 走看看