DESC is the command in MySQL to view the table structure, using the syntax: DESC table_name. It outputs field information including name, type, null value allowed, index status, default value, and additional information. For example: DESC customers returns id (int, primary key, auto-increment), name (varchar(255), allows null values, has index), email (varchar(255), does not allow null values, unique index), phone (varchar() 255), allowing null values, with indexes), address (text, allowing null values, with indexes) and other field information.
What is DESC in MySQL?
DESC is a command in MySQL used to display the table structure. It lists all the fields in the table and their properties in human-readable form.
How to use DESC?
To use the DESC command, simply enter the following syntax at the MySQL prompt:
<code>DESC table_name;</code>
where table_name
is the name of the table whose structure you want to query.
DESC Command Output
The DESC command will return the following information:
Example
For example, to view the customers
table structure, you can use the following command:
<code>DESC customers;</code>
The output may look like this:
<code>Field Type Null Key Default Extra ---------------- -------- -------- -------- -------- -------- id int NO PRI NULL auto_increment name varchar(255) NO MUL NULL email varchar(255) NO UNI NULL phone varchar(255) YES MUL NULL address text YES MUL NULL </code>
The above is the detailed content of What is desc in mysql. For more information, please follow other related articles on the PHP Chinese website!