How to get all columns' names for all the tables in MySQL?
To list all the fields from a table in MySQL:
select *
from information_schema.columns
where table_schema = 'your_DB_name'
and table_name = 'Your_tablename'
select column_name from information_schema.columns
where table_schema = 'your_db'
order by table_name,ordinal_position
it is better that you use the following query to get all column names easily
Show columns from tablename
SELECT * FROM information_schema.columns
WHERE table_schema = DATABASE()
ORDER BY table_name, ordinal_position
Since I don't have enough rep to comment, here's a minor improvement (in my view) over nick rulez's excellent answer: replacing WHERE table_schema = 'your_db'
with WHERE table_schema = DATABASE()
.