Get lists of all column names from database table
Get lists of all column names and other information from the database table in MySQL using INFORMATION_SCHEMA.COLUMNS.
All column names with their original order:
SELECT GROUP_CONCAT( COLUMN_NAME ) AS column_names
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'tmp_hero_employee'
ORDER BY `COLUMNS`.`ORDINAL_POSITION` ASC
There is query for list of all column names in a table that do not have NULL as their default value:
SELECT*FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name ='my_table'AND column_default is[not]null;

Post a Comment