Getting Table Metadata (ADO.Net)

You can get the table metadata by using the GetSchema() method on a connection and loading the metadata into a DataTable:

DataTable table = _conn.GetSchema("Tables", new string[] { database_name, schema_name, table_name, table_type });

For example:

DataTable table = _conn.GetSchema("Tables", new string[] { null, null, null, "SYSTEM TABLE" });

database_name, schema_name, table_name can be set to null, be a specific name, or use a LIKE pattern.

table_type can be one of:

If table_type is set to null, then the metadata for all metadata tables is returned.

Example Usage:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Vertica.Data.VerticaClient;
namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {

//configure connection properties

            VerticaConnectionStringBuilder builder = new VerticaConnectionStringBuilder();
            builder.Host = "192.168.1.10";
            builder.Database = "VMart";
            builder.User = "dbadmin";

//open the connection

            VerticaConnection _conn = new VerticaConnection(builder.ToString());
            _conn.Open();

//create a new data table containing the schema

            //the last argument can be "SYSTEM TABLE", "TABLE", "GLOBAL TEMPORARY",
             // "LOCAL TEMPORARY", "VIEW", or null for all types
            DataTable table = _conn.GetSchema("Tables", new string[] { null, null, null, "SYSTEM TABLE" });            

//print out the schema

            foreach (DataRow row in table.Rows)            {
                foreach (DataColumn col in table.Columns)
                {
                    Console.WriteLine("{0} = {1}", col.ColumnName, row[col]);
                }
                Console.WriteLine("============================");
            }

//close the connection

            _conn.Close();
        }
    }
}