When I am writing code to go with a certain MySQL query, I like to do a basic select statement to see the columns, and to perhaps see what data is available as a sample. Sometimes, the table I would like to look at has no data, so I get a completely empty query.
Now, I know I can use something like "show create table [table_name]" to see the query; similarly, I am aware that it's possible to show the tables with a join statement, but the syntax is just complex enough that I don't always remember it, and I don't want to add complexity to every simply query I want to make, just to handle the occasional empty table.
Thus, I was wondering: is there a setting in MySQL's client, that would allow me to see the column names every time, even when the table is empty?
Best Answer
This will always return a single row with
NULL
in all the columns of the table:This will always return a single row with
NULL
in all the columns of the table if the table is empty and real data from one row if it isn't empty: