How to get all the information about mysql table using C #?

I want to get this information for mysql table using c #

1) Full definition of columns, including name, size and data type, as well as additional information such as null / not null, unsigned, auto increament, default values, if the data type is an enumeration, accepted values

2) All restrictions - primary / external / check / unique

3) All indices

I can get the basic information associated with the column using the query "describe table_name" in the database.

but how to get all this information?

Regards, Anjan

+5
source share
2 answers

just throw requests with INFORMATION_SCHEMA ...

For example, to get column definitions:

SELECT   TABLE_NAME
       , COLUMN_NAME
       , DATA_TYPE
       , CHARACTER_MAXIMUM_LENGTH
       , CHARACTER_OCTET_LENGTH 
       , NUMERIC_PRECISION 
       , NUMERIC_SCALE AS SCALE
       , COLUMN_DEFAULT
       , IS_NULLABLE
FROM INFORMATION_SCHEMA.COLUMNS 

, .

, .

+6

SqlDataReader.GetSchemaTable(), 1), , , , ​​ () .  ( INFORMATION_SCHEMA).

.

, SqlClientMetaDataCollectionNames.

+2

All Articles