tags:

views:

1988

answers:

3

When you call DbConnection.GetSchema you give it the string name of a collection you are interested in. I can't find a list of collections anywhere. Is the list of collections immutable or does it vary by database type (orcle, sql server, etc.)?

I'm interested in getting a list of all collection names in a few database types such as sql server, and sqlite.

+1  A: 

I use an OleDbConnection even if I'm connecting with Oracle, Sql Server... Then I can use:

myOleDbConnection.GetSchema(OleDbSchemGuid.Tables);

Possible values for OleDbSchemaGuid:
(note that depending of the database some of these can throw a NotSupported Exception:

OleDbSchemaGuid.Assertions;
OleDbSchemaGuid.Catalogs;
OleDbSchemaGuid.Character_Sets;
OleDbSchemaGuid.Check_Constraints;
OleDbSchemaGuid.Check_Constraints_By_Table;
OleDbSchemaGuid.Collations;
OleDbSchemaGuid.Column_Domain_Usage;
OleDbSchemaGuid.Column_Privileges;
OleDbSchemaGuid.Columns;
OleDbSchemaGuid.Constraint_Column_Usage;
OleDbSchemaGuid.Constraint_Table_Usage;
OleDbSchemaGuid.DbInfoKeywords;
OleDbSchemaGuid.DbInfoLiterals;
OleDbSchemaGuid.Foreign_Keys;
OleDbSchemaGuid.Indexes;
OleDbSchemaGuid.Key_Column_Usage;
OleDbSchemaGuid.Primary_Keys;
OleDbSchemaGuid.Procedure_Columns;
OleDbSchemaGuid.Procedure_Parameters;
OleDbSchemaGuid.Procedures;
OleDbSchemaGuid.Provider_Types;
OleDbSchemaGuid.Referential_Constraints;
OleDbSchemaGuid.SchemaGuids;
OleDbSchemaGuid.Schemata;
OleDbSchemaGuid.Sql_Languages;
OleDbSchemaGuid.Statistics;
OleDbSchemaGuid.Table_Constraints;
OleDbSchemaGuid.Table_Privileges;
OleDbSchemaGuid.Table_Statistics;
OleDbSchemaGuid.Tables;
OleDbSchemaGuid.Tables_Info;
OleDbSchemaGuid.Translations;
OleDbSchemaGuid.Trustee;
OleDbSchemaGuid.Usage_Privileges;
OleDbSchemaGuid.View_Column_Usage;
OleDbSchemaGuid.View_Table_Usage;
OleDbSchemaGuid.Views;
JAG
+1  A: 

For System.Data.SQLite I finally found what is supported:

http://sqlite.phxsoftware.com/readme.htm

"DbConnection.GetSchema(...) support includes ReservedWords, MetaDataCollections, DataSourceInformation, DataTypes, Columns, Tables, Views, ViewColumns, Catalogs, Indexes, IndexColumns, ForeignKeys and Triggers. "

I think sql server would be about the same, but I still have no definitive list.

P a u l
+1  A: 

The list varies by provider. For this reason, some Common Schema Collections have been defined, that are always available regardless of the provider. One of them is the MetaDataCollections collection, which will return a DataTable with a list of the supported schema collections for the current provider, the number of restrictions that they each support, and the number of identifier parts that they use.

RedFilter

related questions