Beispiel #1
0
		public MetaTableCollection GetTables(bool includeSystemTables) 
		{
			if(con.State != ConnectionState.Open)
				con.Open();

			MetaTableCollection tables = new MetaTableCollection ();

			string sql = 
				"SELECT name " +
				"FROM sqlite_master " +
				"WHERE type = 'table' " +
				"ORDER BY name";

			IDbCommand cmd = con.CreateCommand();
			cmd.CommandText = sql;

			IDataReader reader = cmd.ExecuteReader();
			while(reader.Read())
			{
				MetaTable table = new MetaTable(reader.GetString(0));
				tables.Add(table);
			}
			reader.Close();
			reader = null;
			
			return tables;
		}
Beispiel #2
0
        public MetaTableCollection GetTables(bool includeSystemTables)
        {
            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }

            MetaTableCollection tables = new MetaTableCollection();

            string sql =
                "select schemaname, tablename " +
                "from pg_tables";

            sql = sql + " ORDER BY 1,2";

            IDbCommand cmd = con.CreateCommand();

            cmd.CommandText = sql;

            IDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                MetaTable table = new MetaTable(reader.GetString(0), reader.GetString(1));
                tables.Add(table);
            }
            reader.Close();
            reader = null;

            return(tables);
        }
Beispiel #3
0
		public MetaTableCollection GetTables(bool includeSystemTables) 
		{
			if(con.State != ConnectionState.Open)
				con.Open();

			MetaTableCollection tables = new MetaTableCollection ();

			string sql = 
				"select schemaname, tablename " +
				"from pg_tables";

			sql = sql + " ORDER BY 1,2";

			IDbCommand cmd = con.CreateCommand();
			cmd.CommandText = sql;

			IDataReader reader = cmd.ExecuteReader();
			while(reader.Read()) {
				MetaTable table = new MetaTable(reader.GetString(0), reader.GetString(1));
				tables.Add(table);
			}
			reader.Close();
			reader = null;
			
			return tables;
		}
Beispiel #4
0
		public MetaTableCollection GetTables(bool includeSystemTables) 
		{
			if(con.State != ConnectionState.Open)
				con.Open();

			MetaTableCollection tables = new MetaTableCollection ();

			string where;
			if(includeSystemTables == true)
				where = "";
			else
				where = "WHERE OWNER NOT IN ('SYS','SYSTEM','MDSYS','CTXSYS','WMSYS','WKSYS')";

			string sql = "SELECT OWNER, TABLE_NAME, TABLESPACE_NAME " +
						 "FROM ALL_TABLES " +
						 where + 
						 " ORDER BY 1, 2";

			IDbCommand cmd = con.CreateCommand();
			cmd.CommandText = sql;

			IDataReader reader = cmd.ExecuteReader();
			while(reader.Read())
			{
				MetaTable table = new MetaTable(reader.GetString(0),
					reader.GetString(1));
				tables.Add(table);
			}
			reader.Close();
			reader = null;
			
			return tables;
		}
Beispiel #5
0
        public MetaTableCollection GetTables(bool includeSystemTables)
        {
            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }

            MetaTableCollection tables = new MetaTableCollection();

            string sql =
                "SELECT name " +
                "FROM sqlite_master " +
                "WHERE type = 'table' " +
                "ORDER BY name";

            IDbCommand cmd = con.CreateCommand();

            cmd.CommandText = sql;

            IDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                MetaTable table = new MetaTable(reader.GetString(0));
                tables.Add(table);
            }
            reader.Close();
            reader = null;

            return(tables);
        }
Beispiel #6
0
        public MetaTableCollection GetTables(bool includeSystemTables)
        {
            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }

            MetaTableCollection tables = new MetaTableCollection();

            string sql = "";

            if (infoSchemaExists)
            {
                sql = "select table_schema, table_name, " +
                      " table_type from INFORMATION_SCHEMA.TABLES";
            }
            else
            {
                sql = "SHOW TABLES";
            }

            IDbCommand cmd = con.CreateCommand();

            cmd.CommandText = sql;

            IDataReader reader = null;

            try {
                reader = cmd.ExecuteReader();
            }
            catch (Exception e) {
                infoSchemaExists = false;
                sql    = "SHOW TABLES";
                reader = cmd.ExecuteReader();
            }

            while (reader.Read())
            {
                MetaTable table = null;

                if (infoSchemaExists)
                {
                    table = new MetaTable(reader.GetString(0), reader.GetString(1));
                }
                else
                {
                    table = new MetaTable(reader.GetString(0));
                }

                tables.Add(table);
            }
            reader.Close( );
            reader = null;

            return(tables);
        }
Beispiel #7
0
		public MetaTableCollection GetTables(bool includeSystemTables) 
		{
			if(con.State != ConnectionState.Open)
				con.Open();

			MetaTableCollection tables = new MetaTableCollection ();
			DataTable table = GetSchema ("Tables", new string[] {null, null, null, "TABLE"});

			for (int r = 0; r < table.Rows.Count; r++) 
			{
				DataRow row = table.Rows[r];
				string tableName = row["TABLE_NAME"].ToString();
				MetaTable mtable = new MetaTable(tableName);
				tables.Add(mtable);
			}
			
			return tables;
		}
Beispiel #8
0
        public MetaTableCollection GetTables(bool includeSystemTables)
        {
            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }

            MetaTableCollection tables = new MetaTableCollection();

            string where;
            if (includeSystemTables == true)
            {
                where = "'U','S'";
            }
            else
            {
                where = "'U'";
            }

            string sql =
                "SELECT su.name AS owner, so.name as table_name, so.id as table_id, " +
                " so.crdate as created_date, so.xtype as table_type " +
                "FROM dbo.sysobjects so, dbo.sysusers su " +
                "WHERE xtype IN (" + where + ") " +
                "AND su.uid = so.uid " +
                "ORDER BY 1, 2";

            IDbCommand cmd = con.CreateCommand();

            cmd.CommandText = sql;

            IDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                MetaTable table = new MetaTable(reader.GetString(0),
                                                reader.GetString(1));
                tables.Add(table);
            }
            reader.Close();
            reader = null;

            return(tables);
        }
Beispiel #9
0
		public MetaTableCollection GetTables(bool includeSystemTables) 
		{
			if(con.State != ConnectionState.Open)
				con.Open();

			MetaTableCollection tables = new MetaTableCollection ();

			string sql  = "";
			if (infoSchemaExists)
				sql = "select table_schema, table_name, " +
					" table_type from INFORMATION_SCHEMA.TABLES";
			else
				sql = "SHOW TABLES";

			IDbCommand cmd = con.CreateCommand();
			cmd.CommandText = sql;

			IDataReader reader = null;
			try {
				reader = cmd.ExecuteReader();
			}
			catch(Exception e) {
				infoSchemaExists = false;
				sql = "SHOW TABLES";
				reader = cmd.ExecuteReader();
			}

			while (reader.Read ()) {
				MetaTable table = null;
				
				if (infoSchemaExists)
					table = new MetaTable (reader.GetString (0), reader.GetString (1));
				else
					table = new MetaTable (reader.GetString (0));

				tables.Add(table);
			}
			reader.Close( );
			reader = null;
			
			return tables;
		}
Beispiel #10
0
        public MetaTableCollection GetTables(bool includeSystemTables)
        {
            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }

            MetaTableCollection tables = new MetaTableCollection();
            DataTable           table  = GetSchema("Tables", new string[] { null, null, null, "TABLE" });

            for (int r = 0; r < table.Rows.Count; r++)
            {
                DataRow   row       = table.Rows[r];
                string    tableName = row["TABLE_NAME"].ToString();
                MetaTable mtable    = new MetaTable(tableName);
                tables.Add(mtable);
            }

            return(tables);
        }
Beispiel #11
0
        public MetaTableCollection GetTables(bool includeSystemTables)
        {
            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }

            MetaTableCollection tables = new MetaTableCollection();

            string where;
            if (includeSystemTables == true)
            {
                where = "";
            }
            else
            {
                where = "WHERE OWNER NOT IN ('SYS','SYSTEM','MDSYS','CTXSYS','WMSYS','WKSYS')";
            }

            string sql = "SELECT OWNER, TABLE_NAME, TABLESPACE_NAME " +
                         "FROM ALL_TABLES " +
                         where +
                         " ORDER BY 1, 2";

            IDbCommand cmd = con.CreateCommand();

            cmd.CommandText = sql;

            IDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                MetaTable table = new MetaTable(reader.GetString(0),
                                                reader.GetString(1));
                tables.Add(table);
            }
            reader.Close();
            reader = null;

            return(tables);
        }
Beispiel #12
0
		public MetaTableCollection GetTables(bool includeSystemTables) 
		{
			if(con.State != ConnectionState.Open)
				con.Open();

			MetaTableCollection tables = new MetaTableCollection ();

			string where;
			if(includeSystemTables == true)
				where = "'U','S'";
			else
				where = "'U'";

			string sql = 
				"SELECT su.name AS owner, so.name as table_name, so.id as table_id, " +
				" so.crdate as created_date, so.xtype as table_type " +
				"FROM dbo.sysobjects so, dbo.sysusers su " +
				"WHERE xtype IN (" + where + ") " +
				"AND su.uid = so.uid " +
				"ORDER BY 1, 2";

			IDbCommand cmd = con.CreateCommand();
			cmd.CommandText = sql;

			IDataReader reader = cmd.ExecuteReader();
			while(reader.Read())
			{
				MetaTable table = new MetaTable(reader.GetString(0),
					reader.GetString(1));
				tables.Add(table);
			}
			reader.Close();
			reader = null;
			
			return tables;
		}