Foreword: Recently in the internship, to do with the MySQL related development, think of a long time ago a pen test--to see the database table structure of what kinds of methods;
(i) using the describe statement
Or
DESC table_name;
The latter is the shorthand form of the former. This method is the simplest statement.
(ii) SHOW columns statement
from table_name;
The effect is the same as above.
(iii) SHOW CREATE statement
CREATE TABLE table_name;
This statement differs from the above in that it is used primarily to display MySQL statements that create a particular table (which can also be used to display SQL statements created by the database).
(iv) Querying from the INFORMATION_SCHEMA database
SELECT * from information_schema. COLUMNSWHERE='table_name'\g
This statement can view the details of the table.
From the official MySQL documentation, you can tell: Information_schema is a standalone database that holds instance data for all other databases, that is, metadata for other databases, including database names, table names, column names, and so on. Of course Information_shema is a read-only database.
Using the above statement, you can switch to the INFORMATION_SCHEMA database using use, or you can directly access the corresponding table information in the form of "database name _ table name" above.
View MySQL table structure