5

I'm using terminal for mysql

I want to know what column my table has, but it's empty and dont show anything to me

  • Show Databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+
  • Use test

Database changed

  • Show Tables;
+----------------+
| Tables_in_test |
+----------------+
| tblPerson      |
| tblStudent     |
+----------------+

What Should I do to see the column of my table, even if its empty, like this:

+----+-----------------+---------+
| id | name            | is_male |
+----+-----------------+---------+
|    |                 |         |
+----+-----------------+---------+

not this:

Empty set (0.00 sec)
Ali Rn
  • 1,114
  • 8
  • 19

3 Answers3

8

Type this command you will get the column names of your table.

desc tblPerson;
Kaleemullah
  • 446
  • 3
  • 8
2

Show table structure: describe [table]; or desc [table];

Manish Sharma
  • 210
  • 3
  • 12
2

You can use describe, of course. You can also use information_schema.columns. Or, you can just select:

select p.*
from tblPerson p
limit 0;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786