Home > Database > Mysql Tutorial > How to query field name in mysql

How to query field name in mysql

青灯夜游
Release: 2022-06-16 12:44:32
Original
15055 people have browsed it

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.

How to query field name in mysql

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表名;
Copy after login

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>
Copy after login

How to query field name in mysql

Step 2, use the USE command to switch to the specified database (for example mydb):

USE 数据库名
Copy after login

How to query field name in mysql

Step 3, use the DESCRIBE/DESC command to display the field information of the specified table.

DESCRIBE  users;
Copy after login

How to query field name in mysql

DESC mip_demo;
Copy after login

How to query field name in mysql

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template