Example #1
0
        private TableAnalyser GetRefsTA()
        {
            var res = AnalyserCache.GetTableAnalyser("refs");

            if (res != null)
            {
                return(res);
            }
            var ta = new TableAnalyser();

            foreach (var row in CachedQueryRows(SqlScripts.getrefs))
            {
                var key = new TableAnalyser.Key();
                key.keytype = "FOREIGN KEY";

                key.deleterule = row.SafeString("DELETE_RULE");

                key.keyname   = row["FK_CONSTRAINT"].ToString();
                key.tblname   = row["FK_TABLE"].ToString();
                key.tblschema = row["FK_OWNER"].ToString();

                key.dstpkschema = row["R_OWNER"].ToString();
                key.dstpkname   = row["R_CONSTRAINT"].ToString();

                key.dsttblschema = row["R_OWNER"].ToString();
                key.dsttblname   = row["R_TABLE"].ToString();

                ta.keys.Add(key);
            }

            foreach (var row in CachedQueryRows(SqlScripts.getrefcols))
            {
                var col = new TableAnalyser.Col();
                col.keytype = "FOREIGN KEY";

                col.keyname   = row["FK_CONSTRAINT"].ToString();
                col.tblname   = row["FK_TABLE"].ToString();
                col.tblschema = row["FK_OWNER"].ToString();
                col.colname   = row["FK_COLUMN_NAME"].ToString();

                col.dstcolname = row["R_COLUMN_NAME"].ToString();

                ta.cols.Add(col);
            }

            AnalyserCache.PutTableAnalyser("refs", ta);
            return(ta);
        }
Example #2
0
        private TableAnalyser GetIndexesTA()
        {
            var res = AnalyserCache.GetTableAnalyser("indexes");

            if (res != null)
            {
                return(res);
            }
            var ta = new TableAnalyser();

            ta.AllowDeduceFromColumns = false;
            foreach (var row in CachedQueryRows(SqlScripts.getindexes))
            {
                var key = new TableAnalyser.Key();
                key.keytype = "INDEX";

                key.keyname   = row["INDEX_NAME"].ToString();
                key.keyschema = row["TABLE_OWNER"].ToString();

                key.tblname   = row["TABLE_NAME"].ToString();
                key.tblschema = row["TABLE_OWNER"].ToString();

                key.keyisunique = row["UNIQUENESS"].SafeToString() == "UNIQUE";

                ta.keys.Add(key);
            }

            foreach (var row in CachedQueryRows(SqlScripts.getindexcols))
            {
                var col = new TableAnalyser.Col();
                col.keytype = "INDEX";

                col.keyschema = row["USERNAME"].ToString();
                col.keyname   = row["INDEX_NAME"].ToString();
                col.colname   = row["COLUMN_NAME"].ToString();

                col.ordinal = row["COLUMN_POSITION"].ToString();

                ta.cols.Add(col);
            }

            AnalyserCache.PutTableAnalyser("indexes", ta);
            return(ta);
        }