Query method: 1. In the cmd window, execute the "mysql -u root -p" command to log in to the MySQL database; 2. Use the USE command to switch to the specified database, the syntax is "USE database name;"; 3 . Use the DESCRIBE or DESC command to query the field name. The syntax is "DESCRIBE table name;" or "DESC table name;". The output result is in table form, showing the field information of the table, including field name, field data type, etc., where " The data under the "Field" column is the field name.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
In mysql, you can use the DESCRIBE/DESC command to query the field name.
DESCRIBE/DESC command statement will display the field information of the table in the form of a table, including field name, field data type, whether it is the primary key, whether there is a default value, etc. The syntax format is as follows:
DESCRIBE 表名; //或简写成: DESC表名;
Steps to use the DESCRIBE/DESC command:
Step 1, log in to the MySQL database
In the cmd command window, executemysql -u root -p
command and enter the password
>mysql -u root -p Enter password: ********** mysql>
Step 2, use the USE command to switch to the specified database (for example mydb):
USE 数据库名
Step 3, use the DESCRIBE/DESC command to display the field information of the specified table.
DESCRIBE users;
DESC mip_demo;
As you can see, the data under the Field column of the output table is the field name.
[Related recommendations:mysql video tutorial]
The above is the detailed content of How to query field name in mysql. For more information, please follow other related articles on the PHP Chinese website!