77b65bea-e766-4e3c-a1ed-c4c2534b6019 true D0001-SQL-11.sdt.local jazz dev master Prod true <ProgramFilesX64>\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\Newtonsoft.Json.dll Amazon.Lambda.S3Events AWSSDK.Core AWSSDK.S3 Amazon Amazon.Auth.AccessControlPolicy Amazon.Auth.AccessControlPolicy.ActionIdentifiers Amazon.Internal Amazon.Lambda.S3Events Amazon.MissingTypes Amazon.Runtime Amazon.Runtime.CredentialManagement Amazon.Runtime.CredentialManagement.Internal Amazon.Runtime.EventStreams Amazon.Runtime.EventStreams.Internal Amazon.Runtime.Internal Amazon.Runtime.Internal.Auth Amazon.Runtime.Internal.Settings Amazon.Runtime.Internal.Transform Amazon.Runtime.Internal.Util Amazon.Runtime.SharedInterfaces Amazon.Runtime.SharedInterfaces.Internal Amazon.S3 Amazon.S3.Encryption Amazon.S3.Encryption.Internal Amazon.S3.Internal Amazon.S3.IO Amazon.S3.Model Amazon.S3.Model.Internal.MarshallTransformations Amazon.S3.Transfer Amazon.S3.Util Amazon.Util Amazon.Util.Internal Amazon.Util.Internal.PlatformServices Newtonsoft.Json Newtonsoft.Json.Converters Newtonsoft.Json.Linq Newtonsoft.Json.Schema Newtonsoft.Json.Serialization System System.Diagnostics System.Diagnostics.Tracing System.IO.Compression ThirdParty.BouncyCastle.Asn1 ThirdParty.BouncyCastle.Asn1.Utilities ThirdParty.BouncyCastle.Math ThirdParty.BouncyCastle.OpenSsl ThirdParty.BouncyCastle.Utilities.IO.Pem ThirdParty.Ionic.Zlib ThirdParty.Json.LitJson ThirdParty.MD5 System.Runtime.Remoting.Contexts void Main() { GetColumns(); } public void GetSchema() { var schemata = ExecuteQuery("select * from Information_Schema.SCHEMATA") .GroupBy(g => g.CATALOG_NAME, (Key, Data) => new { Key, Data = Data.OrderBy(d => d.SCHEMA_OWNER).ThenBy(d => d.SCHEMA_NAME).ToList() }) .OrderBy(grp => grp.Key) .ToList(); schemata.Dump(); } public void GetTables(string schema = null) { var tables = ExecuteQuery($"select * from Information_Schema.TABLES AS t WHERE t.TABLE_SCHEMA = '{schema}'") .GroupBy(x => new { x.TABLE_SCHEMA, x.TABLE_TYPE }, (Key, Tables) => new { Schema = Key.TABLE_SCHEMA, Type = Key.TABLE_TYPE, Tables = Tables.Select(ta => ta.TABLE_NAME).OrderBy(ta => ta).ToList() }); tables.Dump(); } public void GetColumns(string schema = null) { // var tableDefs = tables.Where(t => t.Schema == schema).SelectMany(t => t.Tables.Select(ta => // ExecuteQuery($"select * from Information_Schema.COLUMNS AS c WHERE c.TABLE_SCHEMA = '{t.Schema}' AND c.TABLE_NAME = '{ta}'"))); var tableDefs = ExecuteQuery($"select * from Information_Schema.COLUMNS AS c") .GroupBy(c => new Table {TABLE_CATALOG= c.TABLE_CATALOG, TABLE_SCHEMA = c.TABLE_SCHEMA, TABLE_TYPE = c.TABLE_NAME }, (Key, Columns) => new { Key, Columns = Columns.OrderBy(c => c.ORDINAL_POSITION).ToList() }) .OrderBy(c => c.Key.TABLE_CATALOG) .ThenBy(c => c.Key.TABLE_SCHEMA) .ThenBy(c => c.Key.TABLE_NAME); tableDefs.Dump(); } // Define other methods and classes here public class Schemata { public string CATALOG_NAME { get; set; } public string SCHEMA_NAME { get; set; } public string SCHEMA_OWNER { get; set; } } public class Table { public string TABLE_CATALOG { get; set; } public string TABLE_SCHEMA { get; set; } public string TABLE_NAME { get; set; } public string TABLE_TYPE { get; set; } } public class TableColumn { public string TABLE_CATALOG { get; set; } public string TABLE_SCHEMA { get; set; } public string TABLE_NAME { get; set; } public string COLUMN_NAME { get; set; } public int? ORDINAL_POSITION { get; set; } public string COLUMN_DEFAULT { get; set; } public string IS_NULLABLE { get; set; } public string DATA_TYPE { get; set; } public int? CHARACTER_MAXIMUM_LENGTH { get; set; } public int? CHARACTER_OCTET_LENGTH { get; set; } public byte? NUMERIC_PRECISION { get; set; } public short? NUMERIC_PRECISION_RADIX { get; set; } public int? NUMERIC_SCALE { get; set; } public short? DATETIME_PRECISION { get; set; } public string CHARACTER_SET_CATALOG { get; set; } public string CHARACTER_SET_SCHEMA { get; set; } public string CHARACTER_SET_NAME { get; set; } public string COLLATION_CATALOG { get; set; } public string COLLATION_SCHEMA { get; set; } public string COLLATION_NAME { get; set; } public string DOMAIN_CATALOG { get; set; } public string DOMAIN_SCHEMA { get; set; } public string DOMAIN_NAME { get; set; } }