Below Mysql query is very useful to Get list of column name from table with its datatype.
You can get list of all the tables name and all the fields count with help of this query.
In below query just change <–YoursDatabaseName–> to your database and <–YoursTableName–> to your table name where you just want Field values of DESCRIBE statement
//Get total number of TABLES IN a DATABASE
SELECT COUNT(*) AS totalTables
FROM information_schema.tables
WHERE TABLE_SCHEMA = 'YoursDatabaseName'
1 2 3 |
SELECT COUNT(*) AS totalTables FROM information_schema.tables WHERE TABLE_SCHEMA = 'YoursDatabaseName' |
//Get total number of COLUMNS IN a DATABASE
SELECT COUNT(*) AS totalDBColumns
FROM information_schema.columns
WHERE TABLE_SCHEMA = 'YoursDatabaseName'
1 2 3 |
SELECT COUNT(*) AS totalDBColumns FROM information_schema.columns WHERE TABLE_SCHEMA = 'YoursDatabaseName' |
//Get total number of COLUMNS IN a TABLE
SELECT COUNT(*) totalTableColumns
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'YoursTableName' AND
TABLE_SCHEMA = 'YoursDatabaseName'
1 2 3 4 |
SELECT COUNT(*) totalTableColumns FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'YoursTableName' AND TABLE_SCHEMA = 'YoursDatabaseName' |
//Get LIST of COLUMNS NAME AND DATA TYPE
SELECT `COLUMN_NAME`, `DATA_TYPE`
FROM `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_SCHEMA`='YoursDatabaseName'
AND `TABLE_NAME`='YoursTableName';
1 2 3 4 |
SELECT `COLUMN_NAME`, `DATA_TYPE` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA`='YoursDatabaseName' AND `TABLE_NAME`='YoursTableName'; |
//Get LIST of TABLE NAME of ANY Databse
SELECT `TABLE_NAME`
FROM `INFORMATION_SCHEMA`.`TABLES`
WHERE `TABLE_SCHEMA`='YoursDatabaseName'
1 2 3 |
SELECT `TABLE_NAME` FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_SCHEMA`='YoursDatabaseName' |