Get all column names from a mysql table
A quick one: have you ever wanted to get the column names of a mysql table in one column?
You can retrieve the column names of a table by running an SQL query:
select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='tablename'
Of course, remember the replace ‘tablename‘ with the name of your table.
This query will return all your column names in a single column, which is easy to cut and paste. If you want them in a row, open MS Excel and use Paste Special -> transpose your values after you have copied them.
Update: There is a nice summary of how to get column names, including in CSV format, here: https://thispointer.com/mysql-get-column-names/
Recent Comments