In this short post, we are going to learn how to list all columns of every table in a MySQL database.
We want to get the name of the column, the name of the table it belongs to and the type of date for that column.
Query
We will be using a simple SQL query, like this one:
select table_schema, table_name, column_name, data_type from information_schema.columns where table_schema = 'mysql' order by column_name, table_name;
Don’t forget to change the name of the database where you want to list all the columns, that is the “table_schema” value, in the example “mysql“.