A summary of the usage of describe commands in Mysql _mysql

Source: Internet
Author: User

The describe command is used to view detailed design information for a specific table

For example, to view the design information for the guestbook table, use:

Describe Guestbook

describe Ol_user userid 

Second, you can view the column names of the tables in the database through "show Comnus"

There are two ways of using it:
Show columns form table name from database name
Or:
Show columns from database name. Table Name

Third, the use of describe command to query specific columns of information

Describe Guestbook ID

is the column information for the ID field in the query guestbook

{DESCRIBE | DESC} tbl_name [Col_name | wild]

DESCRIBE is the abbreviation for show COLUMNS from.

DESCRIBE provides column information about a table. Col_name can be a column name or a string that contains the SQL wildcard character "%" and "_". It is not necessary to enclose the string in quotation marks.

Mysql> desc Ol_user username\g
1. Row ***************************
 field:username
  type:varchar (MB)
  null:no
  key:mul
Default:
 Extra:
1 row in Set (0.02 sec) 

Determine whether the field exists

mysql_connect (' localhost ', ' root ', ' root ');
mysql_select_db (' demo ');
$test = mysql_query (' Describe cdb_posts a ');
$test = Mysql_fetch_array ($test);

$test [0] Returns the name of the field, for example, I want to query the top field and return the top
If this field does not exist, the return is null, by which you can determine whether a field exists

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.